diff mbox series

ALSA: hda: generic: Remove redundant assignment to dac and dacs[i]

Message ID 1620643295-130162-1-git-send-email-jiapeng.chong@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series ALSA: hda: generic: Remove redundant assignment to dac and dacs[i] | expand

Commit Message

Jiapeng Chong May 10, 2021, 10:41 a.m. UTC
Variable dac and dacs[i] is set to zero, but this value is never read as
it is overwritten or not used later on, hence it is a redundant assignment
and can be removed.

Clean up the following clang-analyzer warning:

sound/pci/hda/hda_generic.c:1436:4: warning: Value stored to 'dac' is
never read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 sound/pci/hda/hda_generic.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Amadeusz Sławiński May 10, 2021, 10:57 a.m. UTC | #1
On 5/10/2021 12:41 PM, Jiapeng Chong wrote:
> Variable dac and dacs[i] is set to zero, but this value is never read as
> it is overwritten or not used later on, hence it is a redundant assignment
> and can be removed.
> 
> Clean up the following clang-analyzer warning:
> 
> sound/pci/hda/hda_generic.c:1436:4: warning: Value stored to 'dac' is
> never read [clang-analyzer-deadcode.DeadStores].
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   sound/pci/hda/hda_generic.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
> index b638fc2..cce1bf7 100644
> --- a/sound/pci/hda/hda_generic.c
> +++ b/sound/pci/hda/hda_generic.c
> @@ -1433,7 +1433,6 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
>   			path = snd_hda_add_new_path(codec, dac, pin, 0);
>   		}
>   		if (!path) {
> -			dac = dacs[i] = 0;
>   			badness += bad->no_dac;
>   		} else {
>   			/* print_nid_path(codec, "output", path); */
> 

Not entirely true... dacs is passed by pointer, so value assigned to it 
can be used somewhere else.
diff mbox series

Patch

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index b638fc2..cce1bf7 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -1433,7 +1433,6 @@  static int try_assign_dacs(struct hda_codec *codec, int num_outs,
 			path = snd_hda_add_new_path(codec, dac, pin, 0);
 		}
 		if (!path) {
-			dac = dacs[i] = 0;
 			badness += bad->no_dac;
 		} else {
 			/* print_nid_path(codec, "output", path); */