From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [PATCH] Add human-readable units modifier to vsnprintf() Date: Tue, 22 May 2012 22:10:48 -0700 Message-ID: <1337749848.13111.40.camel@joe2Laptop> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <20120523045023.GE607-RcKxWJ4Cfj3IzGYXcIpNmNLIRw13R84JkQQo+JxHRPFibQn6LdNjmg@public.gmane.org> Sender: linux-bcache-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Kent Overstreet Cc: Tejun Heo , linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org List-Id: linux-bcache@vger.kernel.org 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 print= f_spec *spec) > case ' ': spec->flags |=3D SPACE; break; > case '#': spec->flags |=3D SPECIAL; break; > case '0': spec->flags |=3D ZEROPAD; break; > + case 'h': spec->flags |=3D HUNITS; break; > default: found =3D false; > } > =20 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' /=20 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 =E2=80=98main=E2=80=99: h.c:6:3: warning: unknown conversion type character =E2=80=980=E2=80=99= in format [-Wformat]