linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-fbdev@vger.kernel.org, Helge Deller <deller@gmx.de>
Subject: Re: [PATCH fbtest] Initialize ticks in benchmark()
Date: Wed, 05 Jul 2023 11:32:30 +0200	[thread overview]
Message-ID: <edc39b273f3fb2f92d510f077ab766f02c5caad5.camel@pengutronix.de> (raw)
In-Reply-To: <CAMuHMdXtkfWRZQ2yjoJJu12DaeZoENh0kr-2nOwXKTuKq3aajQ@mail.gmail.com>

Hi Geert,

On Mi, 2023-07-05 at 11:23 +0200, Geert Uytterhoeven wrote:
> Hi Philipp,
> 
> Thanks for your patch!
> 
> On Thu, Jun 29, 2023 at 10:28 AM Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > Fixes a build error 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
> 
> I believe this is a false positive?
> (unless your "long" type has only a single bit ;-)

Yes. I've clarified the commit message in v2.

> But as this is built with -Werror, I agree it is better to play it safe,
> and fix this.
> 
> > 
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> 
> > --- 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 = 0;
> 
> Wouldn't it be better to preinitialize this to 1 instead?
> Else an overzealous compiler might detect possible UB in the division
> below, and more hell might break loose...

Thanks, since we already are working around a confused compiler, this
seems like a good idea. Fixed in v2.

regards
Philipp

      reply	other threads:[~2023-07-05  9:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29  8:28 [PATCH fbtest] Initialize ticks in benchmark() Philipp Zabel
2023-07-05  9:23 ` Geert Uytterhoeven
2023-07-05  9:32   ` Philipp Zabel [this message]

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=edc39b273f3fb2f92d510f077ab766f02c5caad5.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=deller@gmx.de \
    --cc=geert@linux-m68k.org \
    --cc=linux-fbdev@vger.kernel.org \
    /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).