diff mbox series

[v2] Initialize ticks in benchmark()

Message ID 20230705093041.422391-1-p.zabel@pengutronix.de (mailing list archive)
State Handled Elsewhere
Headers show
Series [v2] Initialize ticks in benchmark() | expand

Commit Message

Philipp Zabel July 5, 2023, 9:30 a.m. UTC
Fixes a build error due to a false positive possible uninitialized use
warning with GCC 13:

  util.c: In function 'benchmark':
  util.c:177:17: error: 'ticks' may be used uninitialized [-Werror=maybe-uninitialized]
  util.c:161:14: note: 'ticks' was declared here

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Geert Uytterhoeven July 5, 2023, 9:46 a.m. UTC | #1
On Wed, Jul 5, 2023 at 11:30 AM Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Fixes a build error due to a false positive possible uninitialized use
> warning with GCC 13:
>
>   util.c: In function 'benchmark':
>   util.c:177:17: error: 'ticks' may be used uninitialized [-Werror=maybe-uninitialized]
>   util.c:161:14: note: 'ticks' was declared here
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Thanks, applied.

Gr{oetje,eeting}s,

                        Geert
Geert Uytterhoeven July 5, 2023, 9:48 a.m. UTC | #2
On Wed, Jul 5, 2023 at 11:46 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, Jul 5, 2023 at 11:30 AM Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > Fixes a build error due to a false positive possible uninitialized use
> > warning with GCC 13:
> >
> >   util.c: In function 'benchmark':
> >   util.c:177:17: error: 'ticks' may be used uninitialized [-Werror=maybe-uninitialized]
> >   util.c:161:14: note: 'ticks' was declared here
> >
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

> Thanks, applied.

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/util.c b/util.c
index cdf89b38618a..f199ace3501b 100644
--- a/util.c
+++ b/util.c
@@ -158,7 +158,7 @@  static uint64_t get_ticks(void)
 
 double benchmark(void (*func)(unsigned long n, void *data), void *data)
 {
-    uint64_t ticks;
+    uint64_t ticks = 1;
     unsigned long n = 1;
 
     printf("Benchmarking... ");