lkml.org 
[lkml]   [2021]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] iio: si1133: fix format string warnings
On Sat, May 29, 2021 at 12:35 AM Joe Perches <joe@perches.com> wrote:
> On Sat, 2021-05-29 at 00:16 +0300, Andy Shevchenko wrote:
> > On Saturday, May 29, 2021, Joe Perches <joe@perches.com> wrote:

...

> > > > > Likely these should be 0x%02x
> > > >
> > > > What’s the difference (except printing 0)?
> > >
> > > (assuming the argument is unsigned char/u8)
> > >
> > > %#02x will always emit more than the specified length (3 or 4 chars)
> > > values < 16 are 0x<hexdigit>, values >= 16 are 0x<hexdigit><hexdigit>
> >
> > 0 will be 0, btw.
>
> Hey Andy. Right.
>
> > > 0x%02x will always emit 4 chars
> >
> > *Minimum* or at least 4 characters. There is an upper limit of sizeof(int)
> > * 2 + 2.
>
> I did write assuming the argument is unsigned char/u8.
> For the general unsigned int arg case, you are of course correct.

Signed char also. Basically for all signed types and unsigned int cases.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2021-05-29 09:53    [W:0.063 / U:0.892 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site