* [PATCH] include: linux/iopoll: fix uninitialized warning
@ 2024-09-03 9:37 Rouven Czerwinski
2024-09-03 11:39 ` Sascha Hauer
2024-09-10 8:25 ` Ahmad Fatoum
0 siblings, 2 replies; 3+ messages in thread
From: Rouven Czerwinski @ 2024-09-03 9:37 UTC (permalink / raw)
To: barebox; +Cc: Rouven Czerwinski
In gcc 13.3 there is a warning that start may be used unitialized:
include/linux/iopoll.h:42:21: warning: ‘start’ may be used uninitialized [-Wmaybe-uninitialized]
42 | is_timeout(start, ((timeout_us) * USECOND))) { \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The warning is bogus since before usage of start !IN_PBL and
timeout_us != 0 are checked for the case where start is used, but in
this case it is also always initialized to get_time_ns().
Initialize it to zero to silence the warning.
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
include/linux/iopoll.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index 96b17dee48..c7dcaec382 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -31,7 +31,7 @@
*/
#define read_poll_timeout(op, val, cond, timeout_us, args...) \
({ \
- uint64_t start; \
+ uint64_t start = 0; \
if (!IN_PBL && (timeout_us) != 0) \
start = get_time_ns(); \
for (;;) { \
--
2.46.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] include: linux/iopoll: fix uninitialized warning
2024-09-03 9:37 [PATCH] include: linux/iopoll: fix uninitialized warning Rouven Czerwinski
@ 2024-09-03 11:39 ` Sascha Hauer
2024-09-10 8:25 ` Ahmad Fatoum
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-09-03 11:39 UTC (permalink / raw)
To: barebox, Rouven Czerwinski
On Tue, 03 Sep 2024 11:37:12 +0200, Rouven Czerwinski wrote:
> In gcc 13.3 there is a warning that start may be used unitialized:
>
> include/linux/iopoll.h:42:21: warning: ‘start’ may be used uninitialized [-Wmaybe-uninitialized]
> 42 | is_timeout(start, ((timeout_us) * USECOND))) { \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The warning is bogus since before usage of start !IN_PBL and
> timeout_us != 0 are checked for the case where start is used, but in
> this case it is also always initialized to get_time_ns().
> Initialize it to zero to silence the warning.
>
> [...]
Applied, thanks!
[1/1] include: linux/iopoll: fix uninitialized warning
https://git.pengutronix.de/cgit/barebox/commit/?id=7485dad4a06c (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] include: linux/iopoll: fix uninitialized warning
2024-09-03 9:37 [PATCH] include: linux/iopoll: fix uninitialized warning Rouven Czerwinski
2024-09-03 11:39 ` Sascha Hauer
@ 2024-09-10 8:25 ` Ahmad Fatoum
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-09-10 8:25 UTC (permalink / raw)
To: Rouven Czerwinski, barebox
Hello Rouven,
On 03.09.24 11:37, Rouven Czerwinski wrote:
> In gcc 13.3 there is a warning that start may be used unitialized:
>
> include/linux/iopoll.h:42:21: warning: ‘start’ may be used uninitialized [-Wmaybe-uninitialized]
> 42 | is_timeout(start, ((timeout_us) * USECOND))) { \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The warning is bogus since before usage of start !IN_PBL and
> timeout_us != 0 are checked for the case where start is used, but in
> this case it is also always initialized to get_time_ns().
> Initialize it to zero to silence the warning.
FTR: Here's the GCC bugzilla report about this false positive:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98049
Thanks for the workaround,
Ahmad
>
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
> include/linux/iopoll.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
> index 96b17dee48..c7dcaec382 100644
> --- a/include/linux/iopoll.h
> +++ b/include/linux/iopoll.h
> @@ -31,7 +31,7 @@
> */
> #define read_poll_timeout(op, val, cond, timeout_us, args...) \
> ({ \
> - uint64_t start; \
> + uint64_t start = 0; \
> if (!IN_PBL && (timeout_us) != 0) \
> start = get_time_ns(); \
> for (;;) { \
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-10 8:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-03 9:37 [PATCH] include: linux/iopoll: fix uninitialized warning Rouven Czerwinski
2024-09-03 11:39 ` Sascha Hauer
2024-09-10 8:25 ` Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox