[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140222025204.GM25940@sirena.org.uk>
Date: Sat, 22 Feb 2014 11:52:04 +0900
From: Mark Brown <broonie@...nel.org>
To: Nenghua Cao <nhcao@...vell.com>
Cc: Liam Girdwood <liam.r.girdwood@...ux.intel.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] asoc: soc-core: fix coccinelle warnings
On Fri, Feb 21, 2014 at 04:06:10PM +0800, Nenghua Cao wrote:
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2413,7 +2413,7 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
> struct snd_kcontrol *kcontrol;
> char *name = NULL;
>
> - memcpy(&template, _template, sizeof(template));
> + memcpy(&template, _template, sizeof(struct snd_kcontrol_new));
> template.index = 0;
>
> if (!long_name)
This looks like a regression - it's better form to use the object name
rather than the type of the object since this prevents errors if the
type changes. What coccinelle was suggesting here was to replace with a
simple assingment statement rather than change the argument within the
memcpy(), I think this stops the warning showing because of that issue
since it makes it harder for coccinelle to figure out that this is a
memcpy() of the whole object.
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists