alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH] ALSA: timer: fix nsec/sec initialization confusion
@ 2020-01-11 20:33 Pierre-Louis Bossart
  2020-01-11 20:41 ` Arnd Bergmann
  2020-01-12  8:43 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2020-01-11 20:33 UTC (permalink / raw)
  To: alsa-devel
  Cc: tiwai, broonie, Pierre-Louis Bossart, Arnd Bergmann, Baolin Wang

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>
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH] ALSA: timer: fix nsec/sec initialization confusion
  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
  2020-01-12  8:43 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-01-11 20:41 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Takashi Iwai, ALSA Development Mailing List, Mark Brown, Baolin Wang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH] ALSA: timer: fix nsec/sec initialization confusion
  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
@ 2020-01-12  8:43 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2020-01-12  8:43 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: alsa-devel, broonie, Arnd Bergmann, Baolin Wang

On Sat, 11 Jan 2020 21:33:25 +0100,
Pierre-Louis Bossart 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>
> Fixes: 07094ae6f9527 ("ALSA: Avoid using timespec for struct snd_timer_tread")
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Applied now.  Thanks.


Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-12  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-01-12  8:43 ` Takashi Iwai

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).