alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Takashi Iwai <tiwai@suse.de>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Mark Brown <broonie@kernel.org>,
	Baolin Wang <baolin.wang@linaro.org>
Subject: Re: [alsa-devel] [PATCH] ALSA: timer: fix nsec/sec initialization confusion
Date: Sat, 11 Jan 2020 21:41:45 +0100	[thread overview]
Message-ID: <CAK8P3a2rVXbYy68iyLR9cR1Y6ztP-73wtLbCyj5OP4U=ar-52g@mail.gmail.com> (raw)
In-Reply-To: <20200111203325.20498-1-pierre-louis.bossart@linux.intel.com>

On Sat, Jan 11, 2020 at 9:33 PM Pierre-Louis Bossart
<pierre-louis.bossart@linux.intel.com> wrote:
>
> GCC reports a warning with W=1:
>
> sound/core/timer.c: In function ‘snd_timer_user_read’:
> sound/core/timer.c:2219:19: warning: initialized field overwritten
> [-Woverride-init]
>  2219 |     .tstamp_sec = tread->tstamp_nsec,
>       |                   ^~~~~
> sound/core/timer.c:2219:19: note: (near initialization for
> ‘(anonymous).tstamp_sec’)
>
> Assigning nsec values to sec fields is problematic in general, even
> more so when the initial goal was to survive the 2030 timer
> armageddon.
>
> Fix by using the proper field in the initialization
>
> Cc: Baolin Wang <baolin.wang@linaro.org>
> Cc: Arnd Bergmann <arnd@arndb.de>

Good catch!

Acked-by: Arnd Bergmann <arnd@arndb.de>

> Fixes: 07094ae6f9527 ("ALSA: Avoid using timespec for struct snd_timer_tread")
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>  sound/core/timer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/core/timer.c b/sound/core/timer.c
> index 8835ff91a893..d9f85f2d66a3 100644
> --- a/sound/core/timer.c
> +++ b/sound/core/timer.c
> @@ -2216,7 +2216,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
>                         tread32 = (struct snd_timer_tread32) {
>                                 .event = tread->event,
>                                 .tstamp_sec = tread->tstamp_sec,
> -                               .tstamp_sec = tread->tstamp_nsec,
> +                               .tstamp_nsec = tread->tstamp_nsec,
>                                 .val = tread->val,
>                         };
>
> --
> 2.20.1
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2020-01-11 20:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-11 20:33 [alsa-devel] [PATCH] ALSA: timer: fix nsec/sec initialization confusion Pierre-Louis Bossart
2020-01-11 20:41 ` Arnd Bergmann [this message]
2020-01-12  8:43 ` Takashi Iwai

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='CAK8P3a2rVXbYy68iyLR9cR1Y6ztP-73wtLbCyj5OP4U=ar-52g@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /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).