Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752704AbdF0LD7 (ORCPT ); Tue, 27 Jun 2017 07:03:59 -0400 Received: from esgaroth.petrovitsch.at ([78.47.184.11]:5461 "EHLO esgaroth.tuxoid.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752112AbdF0LDx (ORCPT ); Tue, 27 Jun 2017 07:03:53 -0400 Message-ID: <1498561379.9962.3.camel@petrovitsch.priv.at> Subject: Re: [PATCH] lib: vsprintf: add printf format conversion %M for errno strings From: Bernd Petrovitsch To: Randy Dunlap , "Enrico Weigelt, metux IT consult" , Joe Perches , linux-kernel@vger.kernel.org In-Reply-To: <3a8df2e2-114c-9f2c-325a-49f234726b08@infradead.org> References: <20170625171230.7613-1-enrico.weigelt@gr13.net> <1498411624.24295.36.camel@perches.com> <6a12988d-bbcc-54e7-be16-eeeb94f88d57@gr13.net> <1498421449.24295.39.camel@perches.com> <71909969-b6be-d116-3372-7add409c1ec1@gr13.net> <3a8df2e2-114c-9f2c-325a-49f234726b08@infradead.org> Content-Type: text/plain; charset="UTF-8" Date: Tue, 27 Jun 2017 13:02:59 +0200 Mime-Version: 1.0 X-Mailer: Evolution 3.22.6 (3.22.6-2.fc25) Content-Transfer-Encoding: 8bit X-DCC-dcc1-Metrics: esgaroth.tuxoid.at 1182; Body=4 Fuz1=4 Fuz2=4 X-Spam-Report: * 0.8 SARE_SUB_PCT_LETTER subject has random-text spamsign * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines * 0.7 AWL AWL: Adjusted score from AWL reputation of From: address Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1347 Lines: 40 Hi all! On Sun, 2017-06-25 at 15:47 -0700, Randy Dunlap wrote: > On 06/25/2017 02:18 PM, Enrico Weigelt, metux IT consult wrote: > > On 25.06.2017 22:10, Joe Perches wrote: > > > > > > Yeah, that's still an open problem. Actually, I still haven't found out, > > > > how it's done w/ all the other kernel-internal conversions. That is hard-coded in gcc ATM TTBOMK (AFAIK BSDs ship patched gcc's for their in-kernel extensions of format strings). > > > Everything else uses "%p", > > > > hmm, but errno's aren't pointers. Isn't %p checked for pointer > > values ? Yup, and gcc will also generate a format string warning/error. > > > > Already was about to do so. Shall I call it strerror() ? > > > > > > I presume kstrerror > > > > > > So use something like > > > "%d: (%s)", errno, kstrerror(errno) > > > > Okay, sounds good. > > but why not just do that in userspace. Sure, you can keep that as your > internal kernel patch, but there's not really much need for it to be in the > mainline kernel.  So when your driver prints "blah: foo bar error 49", > just run a little program that converts 49 to . Userspace can just guess if a given "49" is an errno or not ... MfG, Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at