lkml.org 
[lkml]   [2019]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v4 1/1] printf: add support for printing symbolic error names
Date
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@suse.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)

\
 
 \ /
  Last update: 2019-10-15 15:45    [W:1.047 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site