[alsa-devel] [PATCH] ASoC: core: remove redundunt address operation for array type variable
Takashi Sakamoto
takashi.sakamoto at miraclelinux.com
Mon Mar 13 04:07:43 CET 2017
The type of 'struct snd_ctl_elem_value.value.bytes.data' is 'unsigned
char[512]'. In C language specification, address operation (&) for this
type is just ignored, therefore:
struct snd_ctl_elem_value elem_value;
printf("%p\n", elem_value.value.bytes.data);
printf("%p\n", &elem_value.value.bytes.data);
These two evaluation have the same value, a pointer to the first element
of the array.
This kind of address operation is not good for readers, because it easily
brings confusions as an address operations to pointers. For example,
struct snd_kcontrol_new template;
printf("%p\n", template.name);
printf("%p\n", &template.name);
These two evaluation have the different value. The former is
'unsigned char *', while the latter is 'unsigned char **'.
This commit removes redundant address operation for array type variable
to avoid misreading in reader side.
Cc: Takashi Sakamoto <o-takashi at sakamocchi.jp>
Fixes: f831b055ecec ("ASoC: core: Add support for masking out parts of coefficient blocks")
Signed-off-by: Takashi Sakamoto <takashi.sakamoto at miraclelinux.com>
---
sound/soc/soc-ops.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 500f98c..76b199b 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -658,11 +658,11 @@ int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
ucontrol->value.bytes.data[0] &= ~params->mask;
break;
case 2:
- ((u16 *)(&ucontrol->value.bytes.data))[0]
+ ((u16 *)ucontrol->value.bytes.data)[0]
&= cpu_to_be16(~params->mask);
break;
case 4:
- ((u32 *)(&ucontrol->value.bytes.data))[0]
+ ((u32 *)ucontrol->value.bytes.data)[0]
&= cpu_to_be32(~params->mask);
break;
default:
--
2.9.3
More information about the Alsa-devel
mailing list