From: Takashi Iwai <tiwai@suse.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de
Subject: Re: [PATCH] ALSA: seq: initialize whole fields of automatic variable with union type
Date: Tue, 30 Aug 2016 07:11:52 +0200 [thread overview]
Message-ID: <s5hbn0a4z8n.wl-tiwai@suse.de> (raw)
In-Reply-To: <1472515914-7703-1-git-send-email-o-takashi@sakamocchi.jp>
On Tue, 30 Aug 2016 02:11:54 +0200,
Takashi Sakamoto wrote:
>
> Currently, automatic variable of 'union ioctl_arg' type is initialized
> by designated initialization. Although, the actual effect is interpretation
> of early element of int type and initialization of 'int pversion'.
> Therefore the first field corresponding to int type is initialized to zero.
> This is against my expectation to initialize whole fields.
>
> This commit uses memset() to initialize the variable, instead of designated
> initialization.
>
> Fixes: 04a56dd8ed0d ('ALSA: seq: change ioctl command operation to get data in kernel space')
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
> sound/core/seq/seq_clientmgr.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
> index 286394b..fd50c38 100644
> --- a/sound/core/seq/seq_clientmgr.c
> +++ b/sound/core/seq/seq_clientmgr.c
> @@ -2100,7 +2100,7 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd,
> struct snd_seq_client_pool client_pool;
> struct snd_seq_remove_events remove_events;
> struct snd_seq_query_subs query_subs;
> - } buf = {0};
> + } buf;
> const struct ioctl_handler *handler;
> unsigned long size;
> int err;
> @@ -2114,6 +2114,9 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd,
> }
> if (handler->cmd == 0)
> return -ENOTTY;
> +
> + memset(&buf, 0, sizeof(union ioctl_arg));
The common practice is to pass sizeof(buf).
Takashi
next prev parent reply other threads:[~2016-08-30 5:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-30 0:11 [PATCH] ALSA: seq: initialize whole fields of automatic variable with union type Takashi Sakamoto
2016-08-30 5:11 ` Takashi Iwai [this message]
2016-08-30 6:34 ` Takashi Sakamoto
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=s5hbn0a4z8n.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=o-takashi@sakamocchi.jp \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).