Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752585Ab2EWFKy (ORCPT ); Wed, 23 May 2012 01:10:54 -0400 Received: from perches-mx.perches.com ([206.117.179.246]:59631 "EHLO labridge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751974Ab2EWFKx (ORCPT ); Wed, 23 May 2012 01:10:53 -0400 Message-ID: <1337749848.13111.40.camel@joe2Laptop> Subject: Re: [PATCH] Add human-readable units modifier to vsnprintf() From: Joe Perches To: Kent Overstreet Cc: Tejun Heo , linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, agk@redhat.com Date: Tue, 22 May 2012 22:10:48 -0700 In-Reply-To: <20120523045023.GE607@dhcp-172-18-216-138.mtv.corp.google.com> References: <20120522211706.GH14339@google.com> <20120523031214.GA607@dhcp-172-18-216-138.mtv.corp.google.com> <1337744190.13111.33.camel@joe2Laptop> <20120523045023.GE607@dhcp-172-18-216-138.mtv.corp.google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.2- Content-Transfer-Encoding: 8bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1093 Lines: 38 On Wed, 2012-05-23 at 00:50 -0400, Kent Overstreet wrote: > diff --git a/lib/vsprintf.c b/lib/vsprintf.c [] > @@ -1002,6 +1023,7 @@ int format_decode(const char *fmt, struct printf_spec *spec) > case ' ': spec->flags |= SPACE; break; > case '#': spec->flags |= SPECIAL; break; > case '0': spec->flags |= ZEROPAD; break; > + case 'h': spec->flags |= HUNITS; break; > default: found = false; > } > I think that doesn't work well because gcc __attribute__((format(printf, x, y))) verification fails. It's also possible to confuse it with printf's own 'h' / integer precision use. $ cat h.c #include #include int main(int argc, char** argv) { printf("%h02u\n", 1); return 0; } $ gcc h.c h.c: In function ‘main’: h.c:6:3: warning: unknown conversion type character ‘0’ in format [-Wformat] -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/