[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190626075549.58dbab66@hermes.lan>
Date: Wed, 26 Jun 2019 07:55:49 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Baruch Siach <baruch@...s.co.il>
Cc: Jiri Pirko <jiri@...lanox.com>, netdev@...r.kernel.org,
Aya Levin <ayal@...lanox.com>,
Moshe Shemesh <moshe@...lanox.com>
Subject: Re: [PATCH iproute2 1/2] devlink: fix format string warning for
32bit targets
On Wed, 26 Jun 2019 06:30:44 +0300
Baruch Siach <baruch@...s.co.il> wrote:
> Hi Stephen,
>
> On Tue, Jun 25, 2019 at 11:58:06AM -0700, Stephen Hemminger wrote:
> > On Tue, 25 Jun 2019 14:49:04 +0300
> > Baruch Siach <baruch@...s.co.il> wrote:
> >
> > > diff --git a/devlink/devlink.c b/devlink/devlink.c
> > > index 436935f88bda..b400fab17578 100644
> > > --- a/devlink/devlink.c
> > > +++ b/devlink/devlink.c
> > > @@ -1726,9 +1726,9 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val)
> > > jsonw_u64_field(dl->jw, name, val);
> > > } else {
> > > if (g_indent_newline)
> > > - pr_out("%s %lu", name, val);
> > > + pr_out("%s %llu", name, val);
> > > else
> > > - pr_out(" %s %lu", name, val);
> > > + pr_out(" %s %llu", name, val);
> >
> > But on 64 bit target %llu expects unsigned long long which is 128bit.
>
> Is that a problem?
>
> > The better way to fix this is to use:
> > #include <inttypes.h>
> >
> > And the use the macro PRIu64
> > pr_out(" %s %"PRIu64, name, val);
>
> I think it makes the code harder to read. But OK, I'll post an update to this
> patch and the next.
Or cast val to unsigned long long?
the real problem is devlink's macro's for printing.
If I had been paying attention during initial review, would have forced pr_out to be
a function.
Powered by blists - more mailing lists