[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <904b85b3c32d448abc6b4e58b6c4dc35@AcuMS.aculab.com>
Date: Tue, 15 Oct 2019 13:44:30 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Petr Mladek' <pmladek@...e.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>
CC: Uwe Kleine-König <uwe@...ine-koenig.org>,
Joe Perches <joe@...ches.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Jonathan Corbet <corbet@....net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v4 1/1] printf: add support for printing symbolic error
names
From: Petr Mladek
> Sent: 14 October 2019 14:03
> On Fri 2019-10-11 15:36:17, Rasmus Villemoes wrote:
> > It has been suggested several times to extend vsnprintf() to be able
> > to convert the numeric value of ENOSPC to print "ENOSPC". This
> > implements that as a %p extension: With %pe, one can do
>
> Reviewed-by: Petr Mladek <pmladek@...e.com>
>
> I like the patch. There are only two rather cosmetic things.
>
> > diff --git a/lib/errname.c b/lib/errname.c
> > new file mode 100644
> > index 000000000000..30d3bab99477
> > --- /dev/null
> > +++ b/lib/errname.c
> > +const char *errname(int err)
> > +{
> > + bool pos = err > 0;
> > + const char *name = __errname(err > 0 ? err : -err);
> > +
> > + return name ? name + pos : NULL;
>
> This made me to check C standard. It seems that "true" really has
> to be "1".
What is thus "true" symbol you are talking about?
Actually you could get rid of the "bool" as well.
unsigned int pos = err > 0;
const char *name = __errname(pos ? err : -err);
return name ? &pos[name] : NULL;
then it is all well defined.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists