[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [dm-devel] [PATCH] Add human-readable units modifier to vsnprintf()
- From: Joe Perches <joe perches com>
- To: Kent Overstreet <koverstreet google com>
- Cc: linux-bcache vger kernel org, agk redhat com, Tejun Heo <tejun google com>, linux-kernel vger kernel org, dm-devel redhat com
- Subject: Re: [dm-devel] [PATCH] Add human-readable units modifier to vsnprintf()
- Date: Tue, 22 May 2012 22:10:48 -0700
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 <stdio.h>
#include <stdlib.h>
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]
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]