Skip to contentSkip to conversation

ALSA: cleanups for sparse/cppcheck warnings

PATCH Applied Pierre-Louis Bossart 3 participants 22 messages Sep 2, 2020 – Sep 3, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ALSA: cleanups for sparse/cppcheck warnings

Various cleanups for ALSA core, compressed, hda, usb, ac97 and Digigram cards.

Pierre-Louis Bossart (18):
ALSA: core: pcm: simplify locking for timers
ALSA: core: memalloc: fix fallthrough position
ALSA: core: pcm_memory: dereference pointer after NULL checks
ALSA: core: timer: remove redundant assignment
ALSA: core: timer: clarify operator precedence
ALSA: compress_offload: dereference after checking for NULL pointer
ALSA: compress_offload: remove redundant initialization
ALSA: core: init: use DECLARE_COMPLETION_ONSTACK() macro
ALSA: aoa: i2sbus: use DECLARE_COMPLETION_ONSTACK() macro
ALSA: hda: auto_parser: remove shadowed variable declaration
ALSA: hda: (cosmetic) align function parameters
ALSA: usb: scarless_gen2: fix endianness issue
ALSA: ac97: (cosmetic) align argument names
ALSA: atmel: ac97: clarify operator precedence
ALSA: rawmidi: (cosmetic) align function parameters
ALSA: vx: vx_core: clarify operator precedence
ALSA: vx: vx_pcm: remove redundant assignment
ALSA: vx: vx_pcm: remove redundant assignment

 sound/ac97/ac97_core.h          |  2 +-
 sound/aoa/soundbus/i2sbus/pcm.c |  3 +--
 sound/atmel/ac97c.c             | 22 +++++++++++-----------
 sound/core/compress_offload.c   |  5 +++--
 sound/core/init.c               |  3 +--
 sound/core/memalloc.c           |  2 +-
 sound/core/pcm.c                |  8 +++++---
 sound/core/pcm_memory.c         |  3 ++-
 sound/core/rawmidi.c            |  2 +-
 sound/core/timer.c              |  6 +++---
 sound/drivers/vx/vx_core.c      |  4 ++--
 sound/drivers/vx/vx_pcm.c       |  2 --
 sound/pci/hda/hda_auto_parser.c |  2 +-
 sound/pci/hda/hda_jack.h        |  2 +-
 sound/pci/hda/hda_local.h       |  8 ++++----
 sound/usb/mixer_scarlett_gen2.c |  2 +-
 16 files changed, 38 insertions(+), 38 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/18 ALSA: core: pcm: simplify locking for timers

Fix sparse warning:

sound/core/pcm.c:999:9: warning: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block

There's no real reason to test the same thing twice, and it's simpler have linear sequences.

---
 sound/core/pcm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
sound/core/pcm.c +5 -3
index b6d2331a82f7..be5714f1bb58 100644
@@ -991,11 +991,13 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
 		       PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)));
 	kfree(runtime->hw_constraints.rules);
 	/* Avoid concurrent access to runtime via PCM timer interface */
-	if (substream->timer)
+	if (substream->timer) {
 		spin_lock_irq(&substream->timer->lock);
-	substream->runtime = NULL;
-	if (substream->timer)
+		substream->runtime = NULL;
 		spin_unlock_irq(&substream->timer->lock);
+	} else {
+		substream->runtime = NULL;
+	}
 	kfree(runtime);
 	put_pid(substream->pid);
 	substream->pid = NULL;
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/18 ALSA: core: memalloc: fix fallthrough position

In reply to Pierre-Louis Bossart

Fix cppcheck, the fallthrough only makes sense within the conditional block

sound/core/memalloc.c:161:3: style:inconclusive: Statements following return, break, continue, goto or throw will never be executed. [unreachableCode]
fallthrough;
^

---
 sound/core/memalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/memalloc.c +1 -1
index ad74ea9cbff5..0aeeb6244ff6 100644
@@ -157,8 +157,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
 		 * so if we fail to malloc, try to fetch memory traditionally.
 		 */
 		dmab->dev.type = SNDRV_DMA_TYPE_DEV;
-#endif /* CONFIG_GENERIC_ALLOCATOR */
 		fallthrough;
+#endif /* CONFIG_GENERIC_ALLOCATOR */
 	case SNDRV_DMA_TYPE_DEV:
 	case SNDRV_DMA_TYPE_DEV_UC:
 		snd_malloc_dev_pages(dmab, size);
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/18 ALSA: core: pcm_memory: dereference pointer after NULL checks

In reply to Pierre-Louis Bossart

Fix cppcheck warnings:

sound/core/pcm_memory.c:380:26: warning: Either the condition '!substream' is redundant or there is possible null pointer
dereference: substream. [nullPointerRedundantCheck]

 struct snd_card *card = substream->pcm->card;
                         ^
sound/core/pcm_memory.c:384:6: note: Assuming that condition
'!substream' is not redundant
 if (PCM_RUNTIME_CHECK(substream))
     ^
sound/core/pcm_memory.c:380:26: note: Null pointer dereference
 struct snd_card *card = substream->pcm->card;
                         ^
sound/core/pcm_memory.c:433:26: warning: Either the condition
'!substream' is redundant or there is possible null pointer
dereference: substream. [nullPointerRedundantCheck]
 struct snd_card *card = substream->pcm->card;
                         ^
sound/core/pcm_memory.c:436:6: note: Assuming that condition
'!substream' is not redundant
 if (PCM_RUNTIME_CHECK(substream))
     ^
sound/core/pcm_memory.c:433:26: note: Null pointer dereference
 struct snd_card *card = substream->pcm->card;
                         ^
---
 sound/core/pcm_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/pcm_memory.c +2 -1
index 1bf6a3d9e0c2..4f03ba8ed0ae 100644
@@ -377,7 +377,7 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne
  */
 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size)
 {
-	struct snd_card *card = substream->pcm->card;
+	struct snd_card *card;
 	struct snd_pcm_runtime *runtime;
 	struct snd_dma_buffer *dmab = NULL;
 
@@ -387,6 +387,7 @@ int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size)
 		       SNDRV_DMA_TYPE_UNKNOWN))
 		return -EINVAL;
 	runtime = substream->runtime;
+	card = substream->pcm->card;
 
 	if (runtime->dma_buffer_p) {
 		/* perphaps, we might free the large DMA memory region
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/18 ALSA: core: timer: remove redundant assignment

In reply to Pierre-Louis Bossart

Cppcheck complains about a possible NULL pointer dereference but it actually looks like the NULL assignment is not needed (same loop is used in other parts of the file without it).

---
 sound/core/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/timer.c +1 -1
index 6e27d87b18ed..73ad5ba76b27 100644
@@ -173,7 +173,7 @@ EXPORT_SYMBOL(snd_timer_instance_free);
  */
 static struct snd_timer *snd_timer_find(struct snd_timer_id *tid)
 {
-	struct snd_timer *timer = NULL;
+	struct snd_timer *timer;
 
 	list_for_each_entry(timer, &snd_timer_list, device_list) {
 		if (timer->tmr_class != tid->dev_class)
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/18 ALSA: core: timer: clarify operator precedence

In reply to Pierre-Louis Bossart

fix cppcheck warning:

sound/core/timer.c:1286:9: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

        ? "running" : "stopped");
        ^
---
 sound/core/timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/timer.c +2 -2
index 73ad5ba76b27..227d8152d325 100644
@@ -1280,8 +1280,8 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
 		list_for_each_entry(ti, &timer->open_list_head, open_list)
 			snd_iprintf(buffer, "  Client %s : %s\n",
 				    ti->owner ? ti->owner : "unknown",
-				    ti->flags & (SNDRV_TIMER_IFLG_START |
-						 SNDRV_TIMER_IFLG_RUNNING)
+				    (ti->flags & (SNDRV_TIMER_IFLG_START |
+						  SNDRV_TIMER_IFLG_RUNNING))
 				    ? "running" : "stopped");
 	}
 	mutex_unlock(&register_mutex);
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/18 ALSA: compress_offload: dereference after checking for NULL pointer

In reply to Pierre-Louis Bossart

Fix cppcheck warning and only dereference once the initial checks are done:

sound/core/compress_offload.c:516:38: warning: Either the condition '!stream' is redundant or there is possible null pointer dereference:
stream. [nullPointerRedundantCheck]

 struct snd_compr_runtime *runtime = stream->runtime;
                                     ^
sound/core/compress_offload.c:518:17: note: Assuming that condition
'!stream' is not redundant
if (snd_BUG_ON(!(stream) || !(stream)->runtime))
                ^
sound/core/compress_offload.c:516:38: note: Null pointer dereference
 struct snd_compr_runtime *runtime = stream->runtime;
                                     ^
---
 sound/core/compress_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/compress_offload.c +2 -1
index 0e53f6f31916..e3eb314acb10 100644
@@ -513,10 +513,11 @@ EXPORT_SYMBOL(snd_compr_malloc_pages);
 
 int snd_compr_free_pages(struct snd_compr_stream *stream)
 {
-	struct snd_compr_runtime *runtime = stream->runtime;
+	struct snd_compr_runtime *runtime;
 
 	if (snd_BUG_ON(!(stream) || !(stream)->runtime))
 		return -EINVAL;
+	runtime = stream->runtime;
 	if (runtime->dma_area == NULL)
 		return 0;
 	if (runtime->dma_buffer_p != &stream->dma_buffer) {
Signature · 1 line
2.25.1
maintainer Acked-by on v1 6/18
#7 lore raw

Re: [PATCH 06/18] ALSA: compress_offload: dereference after checking for NULL pointer

Quoted 6 lines · Pierre-Louis Bossart

Fix cppcheck warning and only dereference once the initial checks are done:

sound/core/compress_offload.c:516:38: warning: Either the condition '!stream' is redundant or there is possible null pointer dereference:
stream. [nullPointerRedundantCheck]

Quoted 9 lines
 struct snd_compr_runtime *runtime = stream->runtime;
                                     ^
sound/core/compress_offload.c:518:17: note: Assuming that condition
'!stream' is not redundant
if (snd_BUG_ON(!(stream) || !(stream)->runtime))
                ^
sound/core/compress_offload.c:516:38: note: Null pointer dereference
 struct snd_compr_runtime *runtime = stream->runtime;
                                     ^
Quoted 25 lines
---
 sound/core/compress_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/compress_offload.c +2 -1
index 0e53f6f31916..e3eb314acb10 100644
@@ -513,10 +513,11 @@ EXPORT_SYMBOL(snd_compr_malloc_pages);
 
 int snd_compr_free_pages(struct snd_compr_stream *stream)
 {
-	struct snd_compr_runtime *runtime = stream->runtime;
+	struct snd_compr_runtime *runtime;
 
 	if (snd_BUG_ON(!(stream) || !(stream)->runtime))
 		return -EINVAL;
+	runtime = stream->runtime;
 	if (runtime->dma_area == NULL)
 		return 0;
 	if (runtime->dma_buffer_p != &stream->dma_buffer) {
Signature · 1 line
2.25.1
Signature · 1 line
~Vinod
#8 lore raw

PATCH 7/18 ALSA: compress_offload: remove redundant initialization

In reply to Pierre-Louis Bossart

Fix cppcheck warning:

sound/core/compress_offload.c:1044:6: style: Redundant initialization for 'ret'. The initialized value is overwritten before it is read. [redundantInitialization]

ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS,

     ^
sound/core/compress_offload.c:1034:10: note: ret is initialized
 int ret = -EINVAL;
         ^
sound/core/compress_offload.c:1044:6: note: ret is overwritten
 ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS,
     ^
---
 sound/core/compress_offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/compress_offload.c +1 -1
index e3eb314acb10..c1fec932c49d 100644
@@ -1032,7 +1032,7 @@ static const struct file_operations snd_compr_file_ops = {
 
 static int snd_compress_dev_register(struct snd_device *device)
 {
-	int ret = -EINVAL;
+	int ret;
 	struct snd_compr *compr;
 
 	if (snd_BUG_ON(!device || !device->device_data))
Signature · 1 line
2.25.1
maintainer Acked-by on v1 7/18
#9 lore raw

Re: [PATCH 07/18] ALSA: compress_offload: remove redundant initialization

Quoted 6 lines · Pierre-Louis Bossart

Fix cppcheck warning:

sound/core/compress_offload.c:1044:6: style: Redundant initialization for 'ret'. The initialized value is overwritten before it is read. [redundantInitialization]

Quoted 9 lines

ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS,

     ^
sound/core/compress_offload.c:1034:10: note: ret is initialized
 int ret = -EINVAL;
         ^
sound/core/compress_offload.c:1044:6: note: ret is overwritten
 ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS,
     ^
Quoted 20 lines
---
 sound/core/compress_offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/compress_offload.c +1 -1
index e3eb314acb10..c1fec932c49d 100644
@@ -1032,7 +1032,7 @@ static const struct file_operations snd_compr_file_ops = {
 
 static int snd_compress_dev_register(struct snd_device *device)
 {
-	int ret = -EINVAL;
+	int ret;
 	struct snd_compr *compr;
 
 	if (snd_BUG_ON(!device || !device->device_data))
Signature · 1 line
2.25.1
Signature · 1 line
~Vinod
#10 lore raw

PATCH 8/18 ALSA: core: init: use DECLARE_COMPLETION_ONSTACK() macro

In reply to Pierre-Louis Bossart

Follow recommendation in Documentation/scheduler/completion.rst and use macro to declare local 'struct completion'

---
 sound/core/init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/core/init.c +1 -2
index 0478847ba2b8..764dbe673d48 100644
@@ -519,10 +519,9 @@ EXPORT_SYMBOL(snd_card_free_when_closed);
  */
 int snd_card_free(struct snd_card *card)
 {
-	struct completion released;
+	DECLARE_COMPLETION_ONSTACK(released);
 	int ret;
 
-	init_completion(&released);
 	card->release_completion = &released;
 	ret = snd_card_free_when_closed(card);
 	if (ret)
Signature · 1 line
2.25.1
#11 lore raw

PATCH 9/18 ALSA: aoa: i2sbus: use DECLARE_COMPLETION_ONSTACK() macro

In reply to Pierre-Louis Bossart

Follow recommendation in Documentation/scheduler/completion.rst and use macro to declare local 'struct completion'

---
 sound/aoa/soundbus/i2sbus/pcm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/aoa/soundbus/i2sbus/pcm.c +1 -2
index d350dbd24305..1c8e8131a716 100644
@@ -254,12 +254,11 @@ static void i2sbus_wait_for_stop(struct i2sbus_dev *i2sdev,
 				 struct pcm_info *pi)
 {
 	unsigned long flags;
-	struct completion done;
+	DECLARE_COMPLETION_ONSTACK(done);
 	long timeout;
 
 	spin_lock_irqsave(&i2sdev->low_lock, flags);
 	if (pi->dbdma_ring.stopping) {
-		init_completion(&done);
 		pi->stop_completion = &done;
 		spin_unlock_irqrestore(&i2sdev->low_lock, flags);
 		timeout = wait_for_completion_timeout(&done, HZ);
Signature · 1 line
2.25.1
#12 lore raw

PATCH 10/18 ALSA: hda: auto_parser: remove shadowed variable declaration

In reply to Pierre-Louis Bossart

Fix cppcheck warning:

sound/pci/hda/hda_auto_parser.c:353:7: style: Local variable 'i' shadows outer variable [shadowVariable]

  int i = 0;
      ^
sound/pci/hda/hda_auto_parser.c:182:6: note: Shadowed declaration
 int i;
     ^
sound/pci/hda/hda_auto_parser.c:353:7: note: Shadow variable
  int i = 0;
      ^

It's not clear why a new declaration was added, remove and reuse variable declared with larger scope.

---
 sound/pci/hda/hda_auto_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/hda_auto_parser.c +1 -1
index 824f4ac1a8ce..4dc01647753c 100644
@@ -350,7 +350,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
 	 */
 	if (!cfg->line_outs && cfg->hp_outs > 1 &&
 	    !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) {
-		int i = 0;
+		i = 0;
 		while (i < cfg->hp_outs) {
 			/* The real HPs should have the sequence 0x0f */
 			if ((hp_out[i].seq & 0x0f) == 0x0f) {
Signature · 1 line
2.25.1
#13 lore raw

PATCH 11/18 ALSA: hda: (cosmetic) align function parameters

In reply to Pierre-Louis Bossart

Fix cppcheck warnings and use same names in headers and C code.

---
 sound/pci/hda/hda_jack.h  | 2 +-
 sound/pci/hda/hda_local.h | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
sound/pci/hda/hda_jack.h +1 -1
index 727b6d3ba454..8ceaf0ef5df1 100644
@@ -77,7 +77,7 @@ int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
 
 struct hda_jack_callback *
 snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid,
-					int dev_id, hda_jack_callback_fn cb);
+					int dev_id, hda_jack_callback_fn func);
 
 /**
  * snd_hda_jack_detect_enable - enable the jack-detection
sound/pci/hda/hda_local.h +4 -4
index 8c28b1022f49..5beb8aa44ecd 100644
@@ -100,7 +100,7 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
 int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
 				 struct snd_ctl_elem_value *ucontrol);
 int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
-			  unsigned int size, unsigned int __user *tlv);
+			  unsigned int size, unsigned int __user *_tlv);
 int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
 				  struct snd_ctl_elem_info *uinfo);
 int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
@@ -119,7 +119,7 @@ int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid,
 			     int ch, int dir, int idx, int mask, int val);
 int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
-			     int dir, int idx, int mask, int val);
+			     int direction, int idx, int mask, int val);
 int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch,
 			   int direction, int idx, int mask, int val);
 int snd_hda_codec_amp_init_stereo(struct hda_codec *codec, hda_nid_t nid,
@@ -198,7 +198,7 @@ int snd_hda_input_mux_put(struct hda_codec *codec,
 			  unsigned int *cur_val);
 int snd_hda_add_imux_item(struct hda_codec *codec,
 			  struct hda_input_mux *imux, const char *label,
-			  int index, int *type_index_ret);
+			  int index, int *type_idx);
 
 /*
  * Multi-channel / digital-out PCM helper
@@ -642,7 +642,7 @@ unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
  */
 int snd_hda_enum_helper_info(struct snd_kcontrol *kcontrol,
 			     struct snd_ctl_elem_info *uinfo,
-			     int num_entries, const char * const *texts);
+			     int num_items, const char * const *texts);
 #define snd_hda_enum_bool_helper_info(kcontrol, uinfo) \
 	snd_hda_enum_helper_info(kcontrol, uinfo, 0, NULL)
 
Signature · 1 line
2.25.1
#14 lore raw

PATCH 12/18 ALSA: usb: scarless_gen2: fix endianness issue

In reply to Pierre-Louis Bossart

Fix Sparse warning:

sound/usb/mixer_scarlett_gen2.c:1949:24: warning: cast to restricted __le32

---
 sound/usb/mixer_scarlett_gen2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/mixer_scarlett_gen2.c +1 -1
index 0ffff7640892..d33df146d6ce 100644
@@ -1946,7 +1946,7 @@ static void scarlett2_mixer_interrupt(struct urb *urb)
 		goto requeue;
 
 	if (len == 8) {
-		data = le32_to_cpu(*(u32 *)urb->transfer_buffer);
+		data = le32_to_cpu(*(__le32 *)urb->transfer_buffer);
 		if (data & SCARLETT2_USB_INTERRUPT_VOL_CHANGE)
 			scarlett2_mixer_interrupt_vol_change(mixer);
 		if (data & SCARLETT2_USB_INTERRUPT_BUTTON_CHANGE)
Signature · 1 line
2.25.1
#15 lore raw

PATCH 13/18 ALSA: ac97: (cosmetic) align argument names

In reply to Pierre-Louis Bossart

Fix cppcheck warning:

sound/ac97/bus.c:133:60: style:inconclusive: Function 'snd_ac97_bus_scan_one' argument 1 names different: declaration 'ac97' definition 'adrv'. [funcArgNamesDifferent]

---
 sound/ac97/ac97_core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/ac97/ac97_core.h +1 -1
index 0c5956e4b2f3..5a9677c3d4c3 100644
@@ -3,7 +3,7 @@
  * Copyright (C) 2016 Robert Jarzmik <[email protected]>
  */
 
-unsigned int snd_ac97_bus_scan_one(struct ac97_controller *ac97,
+unsigned int snd_ac97_bus_scan_one(struct ac97_controller *adrv,
 				   unsigned int codec_num);
 
 static inline bool ac97_ids_match(unsigned int id1, unsigned int id2,
Signature · 1 line
2.25.1
#16 lore raw

PATCH 14/18 ALSA: atmel: ac97: clarify operator precedence

In reply to Pierre-Louis Bossart

Fix cppcheck warnings:

sound/atmel/ac97c.c:478:30: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

    casr & AC97C_CSR_OVRUN   ? " OVRUN"   : "",
                             ^
sound/atmel/ac97c.c:479:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    casr & AC97C_CSR_RXRDY   ? " RXRDY"   : "",
                             ^
sound/atmel/ac97c.c:480:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    casr & AC97C_CSR_UNRUN   ? " UNRUN"   : "",
                             ^
sound/atmel/ac97c.c:481:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    casr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
                             ^
sound/atmel/ac97c.c:482:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    casr & AC97C_CSR_TXRDY   ? " TXRDY"   : "",
                             ^
sound/atmel/ac97c.c:524:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    cosr & AC97C_CSR_OVRUN   ? " OVRUN"   : "",
                             ^
sound/atmel/ac97c.c:525:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    cosr & AC97C_CSR_RXRDY   ? " RXRDY"   : "",
                             ^
sound/atmel/ac97c.c:526:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    cosr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
                             ^
sound/atmel/ac97c.c:527:30: style: Clarify calculation precedence for
'&' and '?'. [clarifyCalculation]
    cosr & AC97C_CSR_TXRDY   ? " TXRDY"   : "",
                             ^
---
 sound/atmel/ac97c.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
sound/atmel/ac97c.c +11 -11
index 1006458f7f85..66ecbd4d034e 100644
@@ -475,12 +475,12 @@ static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev)
 		struct snd_pcm_runtime *runtime;
 		int offset, next_period, block_size;
 		dev_dbg(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n",
-				casr & AC97C_CSR_OVRUN   ? " OVRUN"   : "",
-				casr & AC97C_CSR_RXRDY   ? " RXRDY"   : "",
-				casr & AC97C_CSR_UNRUN   ? " UNRUN"   : "",
-				casr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
-				casr & AC97C_CSR_TXRDY   ? " TXRDY"   : "",
-				!casr                    ? " NONE"    : "");
+			(casr & AC97C_CSR_OVRUN)   ? " OVRUN"   : "",
+			(casr & AC97C_CSR_RXRDY)   ? " RXRDY"   : "",
+			(casr & AC97C_CSR_UNRUN)   ? " UNRUN"   : "",
+			(casr & AC97C_CSR_TXEMPTY) ? " TXEMPTY" : "",
+			(casr & AC97C_CSR_TXRDY)   ? " TXRDY"   : "",
+			!casr                      ? " NONE"    : "");
 		if ((casr & camr) & AC97C_CSR_ENDTX) {
 			runtime = chip->playback_substream->runtime;
 			block_size = frames_to_bytes(runtime, runtime->period_size);
@@ -521,11 +521,11 @@ static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev)
 
 	if (sr & AC97C_SR_COEVT) {
 		dev_info(&chip->pdev->dev, "codec channel event%s%s%s%s%s\n",
-				cosr & AC97C_CSR_OVRUN   ? " OVRUN"   : "",
-				cosr & AC97C_CSR_RXRDY   ? " RXRDY"   : "",
-				cosr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
-				cosr & AC97C_CSR_TXRDY   ? " TXRDY"   : "",
-				!cosr                    ? " NONE"    : "");
+			 (cosr & AC97C_CSR_OVRUN)   ? " OVRUN"   : "",
+			 (cosr & AC97C_CSR_RXRDY)   ? " RXRDY"   : "",
+			 (cosr & AC97C_CSR_TXEMPTY) ? " TXEMPTY" : "",
+			 (cosr & AC97C_CSR_TXRDY)   ? " TXRDY"   : "",
+			 !cosr                      ? " NONE"    : "");
 		retval = IRQ_HANDLED;
 	}
 
Signature · 1 line
2.25.1
#17 lore raw

PATCH 15/18 ALSA: rawmidi: (cosmetic) align function parameters

In reply to Pierre-Louis Bossart

fix cppcheck:

sound/core/rawmidi.c:1711:49: style:inconclusive: Function 'snd_rawmidi_free' argument 1 names different: declaration 'rawmidi' definition 'rmidi'. [funcArgNamesDifferent]

---
 sound/core/rawmidi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/rawmidi.c +1 -1
index 2a688b711a9a..c78720a3299c 100644
@@ -35,7 +35,7 @@ module_param_array(amidi_map, int, NULL, 0444);
 MODULE_PARM_DESC(amidi_map, "Raw MIDI device number assigned to 2nd OSS device.");
 #endif /* CONFIG_SND_OSSEMUL */
 
-static int snd_rawmidi_free(struct snd_rawmidi *rawmidi);
+static int snd_rawmidi_free(struct snd_rawmidi *rmidi);
 static int snd_rawmidi_dev_free(struct snd_device *device);
 static int snd_rawmidi_dev_register(struct snd_device *device);
 static int snd_rawmidi_dev_disconnect(struct snd_device *device);
Signature · 1 line
2.25.1
#18 lore raw

PATCH 16/18 ALSA: vx: vx_core: clarify operator precedence

In reply to Pierre-Louis Bossart

Fix cppcheck warning

sound/drivers/vx/vx_core.c:600:49: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

      chip->chip_status & VX_STAT_XILINX_LOADED ? "Loaded" : "No");
                                                ^
sound/drivers/vx/vx_core.c:602:47: style: Clarify calculation
precedence for '&' and '?'. [clarifyCalculation]
      chip->chip_status & VX_STAT_DEVICE_INIT ? "Yes" : "No");
                                              ^
---
 sound/drivers/vx/vx_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/drivers/vx/vx_core.c +2 -2
index 26d591fe6a6b..d5c65cab195b 100644
@@ -597,9 +597,9 @@ static void vx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *b
 	
 	snd_iprintf(buffer, "%s\n", chip->card->longname);
 	snd_iprintf(buffer, "Xilinx Firmware: %s\n",
-		    chip->chip_status & VX_STAT_XILINX_LOADED ? "Loaded" : "No");
+		    (chip->chip_status & VX_STAT_XILINX_LOADED) ? "Loaded" : "No");
 	snd_iprintf(buffer, "Device Initialized: %s\n",
-		    chip->chip_status & VX_STAT_DEVICE_INIT ? "Yes" : "No");
+		    (chip->chip_status & VX_STAT_DEVICE_INIT) ? "Yes" : "No");
 	snd_iprintf(buffer, "DSP audio info:");
 	if (chip->audio_info & VX_AUDIO_INFO_REAL_TIME)
 		snd_iprintf(buffer, " realtime");
Signature · 1 line
2.25.1
#19 lore raw

PATCH 17/18 ALSA: vx: vx_pcm: remove redundant assignment

In reply to Pierre-Louis Bossart

Fix cppcheck warning:

sound/drivers/vx/vx_pcm.c:539:30: style: Variable 'chip->playback_pipes[audio]' is reassigned a value before the old one has been used. [redundantAssignment]

 chip->playback_pipes[audio] = pipe;
                             ^
sound/drivers/vx/vx_pcm.c:533:31: note: chip->playback_pipes[audio] is
assigned
  chip->playback_pipes[audio] = pipe;
                              ^
sound/drivers/vx/vx_pcm.c:539:30: note: chip->playback_pipes[audio] is
overwritten
 chip->playback_pipes[audio] = pipe;
                             ^
---
 sound/drivers/vx/vx_pcm.c | 1 -
 1 file changed, 1 deletion(-)
sound/drivers/vx/vx_pcm.c +0 -1
index 664b9efa9a50..47361e26be80 100644
@@ -530,7 +530,6 @@ static int vx_pcm_playback_open(struct snd_pcm_substream *subs)
 		err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */
 		if (err < 0)
 			return err;
-		chip->playback_pipes[audio] = pipe;
 	}
 	/* open for playback */
 	pipe->references++;
Signature · 1 line
2.25.1
#20 lore raw

PATCH 18/18 ALSA: vx: vx_pcm: remove redundant assignment

In reply to Pierre-Louis Bossart

Fix cppcheck warning:

sound/drivers/vx/vx_pcm.c:63:7: style: Variable 'buf' is assigned a value that is never used. [unreadVariable]

  buf = (unsigned char *)runtime->dma_area;
      ^
---
 sound/drivers/vx/vx_pcm.c | 1 -
 1 file changed, 1 deletion(-)
sound/drivers/vx/vx_pcm.c +0 -1
index 47361e26be80..3d2e3bcafca8 100644
@@ -60,7 +60,6 @@ static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *
 	*buf++ = vx_inb(chip, RXL);
 	if (++offset >= pipe->buffer_bytes) {
 		offset = 0;
-		buf = (unsigned char *)runtime->dma_area;
 	}
 	pipe->hw_ptr = offset;
 }
Signature · 1 line
2.25.1
Applied
#21 lore raw
In reply to Pierre-Louis Bossart
Quoted 15 lines · Pierre-Louis Bossart

Various cleanups for ALSA core, compressed, hda, usb, ac97 and Digigram cards.

Pierre-Louis Bossart (18):
ALSA: core: pcm: simplify locking for timers
ALSA: core: memalloc: fix fallthrough position
ALSA: core: pcm_memory: dereference pointer after NULL checks
ALSA: core: timer: remove redundant assignment
ALSA: core: timer: clarify operator precedence
ALSA: compress_offload: dereference after checking for NULL pointer
ALSA: compress_offload: remove redundant initialization
ALSA: core: init: use DECLARE_COMPLETION_ONSTACK() macro
ALSA: aoa: i2sbus: use DECLARE_COMPLETION_ONSTACK() macro
ALSA: hda: auto_parser: remove shadowed variable declaration

Quoted 8 lines

ALSA: hda: (cosmetic) align function parameters
ALSA: usb: scarless_gen2: fix endianness issue
ALSA: ac97: (cosmetic) align argument names
ALSA: atmel: ac97: clarify operator precedence
ALSA: rawmidi: (cosmetic) align function parameters
ALSA: vx: vx_core: clarify operator precedence
ALSA: vx: vx_pcm: remove redundant assignment
ALSA: vx: vx_pcm: remove redundant assignment

Applied all patches now. Thanks.

Takashi