ASoC: adau17x1: Use empty struct initializer
PATCH 1/3 ASoC: adau17x1: Use empty struct initializer
From: Fabio Estevam <[email protected]>
{ 0 } only clears the first member of the structure.
The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in a sparse warning.
Use the empty struct initializer that clears all the struct members and fixes the sparse warning.
--- sound/soc/codecs/adau17x1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/adau17x1.c +1 -1
@@ -181,7 +181,7 @@ static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol,struct snd_soc_dapm_context *dapm =snd_soc_component_get_dapm (component);struct adau *adau =snd_soc_component_get_drvdata (component);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; -struct snd_soc_dapm_update update = {0 }; +struct snd_soc_dapm_update update = {};unsigned int stream = e->shift_l;unsigned int val, change;int reg;
Signature · 1 line
2.7.4
PATCH 2/3 ASoC: wm9713: Use empty struct initializer
From: Fabio Estevam <[email protected]>
{ 0 } only clears the first member of the structure.
The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in a sparse warning.
Use the empty struct initializer that clears all the struct members and fixes the sparse warning.
--- sound/soc/codecs/wm9713.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm9713.c +1 -1
@@ -235,7 +235,7 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol,struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;unsigned int mixer, mask, shift, old; -struct snd_soc_dapm_update update = {0 }; +struct snd_soc_dapm_update update = {};bool change; mixer = mc->shift >>8 ;
Signature · 1 line
2.7.4
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Quoted 7 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
{ 0 } only clears the first member of the structure.
The first member of the
snd_soc_dapm_updatestruct is a pointer, and writing 0 to a pointer results in a sparse warning.
Quoted 6 lines
Use the empty struct initializer that clears all the struct members and fixes the sparse warning.
Cc Charles Keepax <[email protected]>Signed-off-by Fabio Estevam <[email protected]>---
Thanks,
Charles
Mark Brown
maintainerApplied "ASoC: wm9713: Use empty struct initializer" to the asoc tree
In reply to Fabio EstevamThe patch
ASoC: wm9713: Use empty struct initializer
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
91cd00083d734258bf293dcf76793e2348be391aMon Sep 17 00:00:00 2001
From: Fabio Estevam <[email protected]>
Date: Wed, 14 Feb 2018 13:39:04 -0200
Subject: [PATCH] ASoC: wm9713: Use empty struct initializer
{ 0 } only clears the first member of the structure.
The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in a sparse warning.
Use the empty struct initializer that clears all the struct members and fixes the sparse warning.
--- sound/soc/codecs/wm9713.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm9713.c +1 -1
@@ -235,7 +235,7 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol,struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;unsigned int mixer, mask, shift, old; -struct snd_soc_dapm_update update = {0 }; +struct snd_soc_dapm_update update = {};bool change; mixer = mc->shift >>8 ;
Signature · 1 line
2.16.1
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
In reply to Fabio EstevamQuoted 4 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
{ 0 } only clears the first member of the structure.
Not according to the C99 and C11 standards.
C11 6.7.9.21 (C99 has the same statement):
If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.
C11 6.7.9.10 defines that "objects that have static storage duration" shall be initialized to zero.
So according to both C11 and C99 standards {0} should (and must) initialize the entire structure to zero.
Quoted 3 lines
The first member of the
snd_soc_dapm_updatestruct is a pointer, and writing 0 to a pointer results in a sparse warning.
This is the actual problem you are trying to fix? The comment about { 0 } only clearing the first member is probably bogus, your actual problem is that it should have been { NULL } ?
So the fix works (because of 6.7.9.21 quoted above) but the commit message is incorrect/misleading about what the problem is and why this is a fix for it.
Quoted 23 lines
Use the empty struct initializer that clears all the struct members and fixes the sparse warning.
Cc Charles Keepax <[email protected]>Signed-off-by Fabio Estevam <[email protected]>--- sound/soc/codecs/wm9713.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sound/soc/codecs/wm9713.c +1
-1@@ -235,7 +235,7 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol,struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;unsigned int mixer, mask, shift, old; -struct snd_soc_dapm_update update = {0 }; +struct snd_soc_dapm_update update = {};bool change; mixer = mc->shift >>8 ;
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Quoted 3 lines · Richard Fitzgerald
This is the actual problem you are trying to fix? The comment about { 0 } only clearing the first member is probably bogus, your actual problem is that it should have been { NULL } ?
Changing to { NULL } fixes the sparse warning, but that would be a fragile fix because it relies on the order of the struct members.
If someday the struct changes in a way so that the first member is no longer a pointer, then we will have issues again.
Using {} is more error prone.
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Quoted 1 line · Fabio Estevam
Using {} is more error prone.
I mean, less error prone :-)
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
In reply to Fabio EstevamQuoted 7 lines · Fabio Estevam
Quoted 3 lines · Richard Fitzgerald
This is the actual problem you are trying to fix? The comment about { 0 } only clearing the first member is probably bogus, your actual problem is that it should have been { NULL } ?
Quoted 8 lines
Changing to { NULL } fixes the sparse warning, but that would be a fragile fix because it relies on the order of the struct members.
If someday the struct changes in a way so that the first member is no longer a pointer, then we will have issues again.
Using {} is more error prone.
I agree but your commit message didn't say that. It's irrelevant now Mark has merged the patch, but for anyone looking at the commit message later, the structure of your commit message implies that the problem is that {0} doesn't work correctly (probably untrue and certainly not the actual problem.) and your actual fix relies on precisely the behaviour that the first line of your commit message implies is broken.
I just like commit messages to be accurate about what the problem was and why. It's often said that an incorrect comment is worse than not having the comment at all, and the same could be said for commit messages,
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Quoted 4 lines · Richard Fitzgerald
I agree but your commit message didn't say that. It's irrelevant now Mark has merged the patch, but for anyone looking at the commit message later, the structure of your commit message implies that the problem is that {0} doesn't work correctly (probably untrue and certainly not
Yes, and that is the message I want to give:
{0} does not work correctly if the first member of the struct is a pointer, as we should not explicitly write 0 to pointers.
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Quoted 8 lines · Fabio Estevam
Quoted 4 lines · Richard Fitzgerald
I agree but your commit message didn't say that. It's irrelevant now Mark has merged the patch, but for anyone looking at the commit message later, the structure of your commit message implies that the problem is that {0} doesn't work correctly (probably untrue and certainly not
Quoted 5 lines
Yes, and that is the message I want to give:
{0} does not work correctly if the first member of the struct is a pointer, as we should not explicitly write 0 to pointers.
I gather that, so I'd have liked to your commit message to have said that. But what you actually said was
"{ 0 } only clears the first member of the structure."
which is a very different message.
Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Quoted 6 lines · Richard Fitzgerald
I gather that, so I'd have liked to your commit message to have said that. But what you actually said was
"{ 0 } only clears the first member of the structure."
which is a very different message.
Got it. Maybe I should have written like this instead:
"{ 0 } only clears explicitly the first member of the structure."
Thanks for the feedback.
PATCH 3/3 ASoC: soc-dapm: Use empty struct initializer
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
{ NULL } only clears the first member of the structure.
Even though the first member of the snd_soc_dapm_update struct is a pointer,it is more robust to use the empty struct initializer that clears all the struct members.
--- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-dapm.c +2 -2
@@ -3165,7 +3165,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,unsigned int invert = mc->invert;unsigned int val, rval =0 ;int connect, rconnect =-1 , change, reg_change =0 ; -struct snd_soc_dapm_update update = {NULL }; +struct snd_soc_dapm_update update = {};int ret =0 ; val = (ucontrol->value.integer.value[0 ] & mask);
@@ -3292,7 +3292,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,unsigned int *item = ucontrol->value.enumerated.item;unsigned int val, change, reg_change =0 ;unsigned int mask; -struct snd_soc_dapm_update update = {NULL }; +struct snd_soc_dapm_update update = {};int ret =0 ;if (item[0 ] >= e->items)
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: soc-dapm: Use empty struct initializer" to the asoc tree
The patch
ASoC: soc-dapm: Use empty struct initializer
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
33d9245c6092336420c67f761b3bdcdd6c7c1d5dMon Sep 17 00:00:00 2001
From: Fabio Estevam <[email protected]>
Date: Wed, 14 Feb 2018 13:39:05 -0200
Subject: [PATCH] ASoC: soc-dapm: Use empty struct initializer
{ NULL } only clears the first member of the structure.
Even though the first member of the snd_soc_dapm_update struct is a pointer,it is more robust to use the empty struct initializer that clears all the struct members.
--- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-dapm.c +2 -2
@@ -3165,7 +3165,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,unsigned int invert = mc->invert;unsigned int val, rval =0 ;int connect, rconnect =-1 , change, reg_change =0 ; -struct snd_soc_dapm_update update = {NULL }; +struct snd_soc_dapm_update update = {};int ret =0 ; val = (ucontrol->value.integer.value[0 ] & mask);
@@ -3292,7 +3292,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,unsigned int *item = ucontrol->value.enumerated.item;unsigned int val, change, reg_change =0 ;unsigned int mask; -struct snd_soc_dapm_update update = {NULL }; +struct snd_soc_dapm_update update = {};int ret =0 ;if (item[0 ] >= e->items)
Signature · 1 line
2.16.1
Mark Brown
maintainerApplied "ASoC: adau17x1: Use empty struct initializer" to the asoc tree
In reply to Fabio EstevamThe patch
ASoC: adau17x1: Use empty struct initializer
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
c90ef8c7419180ee873dd64e5ae162d32faca762Mon Sep 17 00:00:00 2001
From: Fabio Estevam <[email protected]>
Date: Wed, 14 Feb 2018 13:39:03 -0200
Subject: [PATCH] ASoC: adau17x1: Use empty struct initializer
{ 0 } only clears the first member of the structure.
The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in a sparse warning.
Use the empty struct initializer that clears all the struct members and fixes the sparse warning.
--- sound/soc/codecs/adau17x1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/adau17x1.c +1 -1
@@ -181,7 +181,7 @@ static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol,struct snd_soc_dapm_context *dapm =snd_soc_component_get_dapm (component);struct adau *adau =snd_soc_component_get_drvdata (component);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; -struct snd_soc_dapm_update update = {0 }; +struct snd_soc_dapm_update update = {};unsigned int stream = e->shift_l;unsigned int val, change;int reg;
Signature · 1 line
2.16.1