Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5900816ybp; Tue, 15 Oct 2019 06:46:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXOAzdXSrc0aIKM66tleiIAX8/0JZRNuQdU+TDyDsUTWcrH5UKsvSX2/od31L6QlyLlsvo X-Received: by 2002:a05:6402:2028:: with SMTP id ay8mr33492116edb.273.1571147176794; Tue, 15 Oct 2019 06:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571147176; cv=none; d=google.com; s=arc-20160816; b=W1wbIQhHkxv3N274sojVo62mrecwu1FFRVgLLNoey0/tJRDfxgv5yqEQnoGfSAk6sJ 1knaNREv5vWuMcWij97m8zTw+GG8TPLxv5UQlDZUXsc7Ujt+lZM22gDLUdrQc6xQxYI5 ledEcksDAetdEcI2LCtHGFo8JMmIWXTn6nSi924cZBktAFBSGCjxSQylRsaR07/zuAM5 XTL+StS48JvsnAbiLOLG4lOiDfBpUuDPuLPd/i2AtffnEklu12Gqun4TukBDWxYLN+1r WE5KuiuOgl13/1AI0cjTEaRPy+pc7yZwykAu/dgxFRzklcCVZi+BUzge3wTktvXtp7xH Z79w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=fnRYEQDgghu9xx2vfXOlAjnXmB+tMeUvaQkToVLfFQc=; b=r7TSbYKrSB1gzV7/3nC89YqIrEbhUShJMySniIf/j1lwkMT3C0x02FZWCKgQaH/inV D75vCbn2GuLmMz9U9gFs48oeFVONnINosprMhsRoJ4TBWKiKLzTRb0s597D72GHPd/2u 9tBdWEkEzUOWujSLRQfUm1fgKvHwC5HA9rNHDUluQbS7EG1bLtCg1FMgEeYIktu46r4A kBCOgQ2UJ6PCqnKIY1pk1P7+0KkelMPxCg0hoiGMnImL4DVF4rUSQfSZxBmNjG8O9+9K 7G/z0tdX8MBhwl5JJu1tC4hGQH93ViHTbehWYoOwtxlf8pidwUZmPEaLG172nnd580M0 jKfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10si13192002ejz.394.2019.10.15.06.45.52; Tue, 15 Oct 2019 06:46:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732129AbfJONoe convert rfc822-to-8bit (ORCPT + 99 others); Tue, 15 Oct 2019 09:44:34 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([146.101.78.151]:52636 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728880AbfJONod (ORCPT ); Tue, 15 Oct 2019 09:44:33 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-191-VZdTs2gWNsGAxBzQDtU9Qw-1; Tue, 15 Oct 2019 14:44:30 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 15 Oct 2019 14:44:30 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 15 Oct 2019 14:44:30 +0100 From: David Laight To: 'Petr Mladek' , Rasmus Villemoes CC: =?iso-8859-1?Q?Uwe_Kleine-K=F6nig?= , Joe Perches , Andy Shevchenko , Andrew Morton , Jonathan Corbet , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v4 1/1] printf: add support for printing symbolic error names Thread-Topic: [PATCH v4 1/1] printf: add support for printing symbolic error names Thread-Index: AQHVgo+xcgMsYRXixUil6/wftqCdMKdbtuyw Date: Tue, 15 Oct 2019 13:44:30 +0000 Message-ID: <904b85b3c32d448abc6b4e58b6c4dc35@AcuMS.aculab.com> References: <20190917065959.5560-1-linux@rasmusvillemoes.dk> <20191011133617.9963-1-linux@rasmusvillemoes.dk> <20191011133617.9963-2-linux@rasmusvillemoes.dk> <20191014130247.rag2g7qz54uiw54z@pathway.suse.cz> In-Reply-To: <20191014130247.rag2g7qz54uiw54z@pathway.suse.cz> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: VZdTs2gWNsGAxBzQDtU9Qw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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)