Skip to content

Commit 24a1dff

Browse files
andy-shevpmladek
authored andcommitted
lib/vsprintf.c: Amend static asserts for format specifier flags
There are couple of improvements to static asserts against the format specifier flags: - new static assert for SIGN - fix static assert for SMALL SMALL is not equal to ASCII code of white space, it equals to the bit difference between capital and small letters (however the value is the same, semantically expression means different things). Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c15b5fc commit 24a1dff

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/vsprintf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,9 @@ int num_to_str(char *buf, int size, unsigned long long num, unsigned int width)
408408
#define SMALL 32 /* use lowercase in hex (must be 32 == 0x20) */
409409
#define SPECIAL 64 /* prefix hex with "0x", octal with "0" */
410410

411+
static_assert(SIGN == 1);
411412
static_assert(ZEROPAD == ('0' - ' '));
412-
static_assert(SMALL == ' ');
413+
static_assert(SMALL == ('a' ^ 'A'));
413414

414415
enum format_type {
415416
FORMAT_TYPE_NONE, /* Just a string part */

0 commit comments

Comments
 (0)