All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Fabio Estevam <festevam@gmail.com>, broonie@kernel.org
Cc: Fabio Estevam <fabio.estevam@nxp.com>,
	alsa-devel@alsa-project.org,
	Charles Keepax <ckeepax@opensource.cirrus.com>
Subject: Re: [PATCH 2/3] ASoC: wm9713: Use empty struct initializer
Date: Wed, 14 Feb 2018 16:41:18 +0000	[thread overview]
Message-ID: <938aa54c-c599-9efc-e78f-4e72db08199e@opensource.cirrus.com> (raw)
In-Reply-To: <1518622745-12162-2-git-send-email-festevam@gmail.com>

On 14/02/18 15:39, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> { 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.

> The first member of the snd_soc_dapm_update struct 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.

> Use the empty struct initializer that clears all the struct members
> and fixes the sparse warning.
> 
> Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>   sound/soc/codecs/wm9713.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
> index 3d6cf00..643863b 100644
> --- a/sound/soc/codecs/wm9713.c
> +++ b/sound/soc/codecs/wm9713.c
> @@ -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;
> 

  parent reply	other threads:[~2018-02-14 16:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 15:39 [PATCH 1/3] ASoC: adau17x1: Use empty struct initializer Fabio Estevam
2018-02-14 15:39 ` [PATCH 2/3] ASoC: wm9713: " Fabio Estevam
2018-02-14 15:48   ` Charles Keepax
2018-02-14 16:28   ` Applied "ASoC: wm9713: Use empty struct initializer" to the asoc tree Mark Brown
2018-02-14 16:41   ` Richard Fitzgerald [this message]
2018-02-14 16:49     ` [PATCH 2/3] ASoC: wm9713: Use empty struct initializer Fabio Estevam
2018-02-14 16:51       ` Fabio Estevam
2018-02-14 16:56       ` Richard Fitzgerald
2018-02-14 17:01         ` Fabio Estevam
2018-02-14 17:15           ` Richard Fitzgerald
2018-02-14 17:19             ` Fabio Estevam
2018-02-14 15:39 ` [PATCH 3/3] ASoC: soc-dapm: " Fabio Estevam
2018-02-14 16:28   ` Applied "ASoC: soc-dapm: Use empty struct initializer" to the asoc tree Mark Brown
2018-02-14 16:28 ` Applied "ASoC: adau17x1: " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=938aa54c-c599-9efc-e78f-4e72db08199e@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=fabio.estevam@nxp.com \
    --cc=festevam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.