Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371AbdFYUKy (ORCPT ); Sun, 25 Jun 2017 16:10:54 -0400 Received: from smtprelay0133.hostedemail.com ([216.40.44.133]:59168 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751334AbdFYUKw (ORCPT ); Sun, 25 Jun 2017 16:10:52 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::,RULES_HIT:41:152:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:7875:7903:8660:10004:10400:10848:11232:11473:11658:11914:12663:12740:12895:13069:13148:13230:13311:13357:13894:14096:14097:14659:14721:21080:21324:21433:21434:21627:30034:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:35,LUA_SUMMARY:none X-HE-Tag: sign99_419423cbdc41f X-Filterd-Recvd-Size: 2057 Message-ID: <1498421449.24295.39.camel@perches.com> Subject: Re: [PATCH] lib: vsprintf: add printf format conversion %M for errno strings From: Joe Perches To: "Enrico Weigelt, metux IT consult" , linux-kernel@vger.kernel.org Date: Sun, 25 Jun 2017 13:10:49 -0700 In-Reply-To: <6a12988d-bbcc-54e7-be16-eeeb94f88d57@gr13.net> References: <20170625171230.7613-1-enrico.weigelt@gr13.net> <1498411624.24295.36.camel@perches.com> <6a12988d-bbcc-54e7-be16-eeeb94f88d57@gr13.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1168 Lines: 35 On Sun, 2017-06-25 at 21:53 +0200, Enrico Weigelt, metux IT consult wrote: > On 25.06.2017 19:27, Joe Perches wrote: > > > Every use of %M is going to cause gcc when using __printf to emit > > a warning like: > > > > unknown conversion type character ‘M’ in format [-Wformat=] > > 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. Everything else uses "%p", > I was under > the impression, there was some magic to tell the compiler which letters > correspond to which types - unfortunately, didn't find anything like > that. Is that really hardcoded in gcc ? > > > Beyond that, why is this useful? > > Use that instead of %d where errno values are printed/logged. > > There can't possibly be any fast-path use. > > I'm using it eg. for driver development - always having to look up the > numbers is quite ugly and time consuming. > > > Why not just create a function that does errno/string conversions? > > Already was about to do so. Shall I call it strerror() ? I presume kstrerror So use something like "%d: (%s)", errno, kstrerror(errno)