]> Git Repo - J-linux.git/commitdiff
lib/vsprintf.c: Amend static asserts for format specifier flags
authorAndy Shevchenko <[email protected]>
Tue, 26 Oct 2021 14:03:56 +0000 (17:03 +0300)
committerPetr Mladek <[email protected]>
Wed, 27 Oct 2021 13:13:47 +0000 (15:13 +0200)
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]
lib/vsprintf.c

index 26c83943748a4beec62bb7f06cec902aa12fba8f..1173930ed9d3396a46c3efe7b192ad6dc74e3b77 100644 (file)
@@ -408,8 +408,9 @@ int num_to_str(char *buf, int size, unsigned long long num, unsigned int width)
 #define SMALL  32              /* use lowercase in hex (must be 32 == 0x20) */
 #define SPECIAL        64              /* prefix hex with "0x", octal with "0" */
 
+static_assert(SIGN == 1);
 static_assert(ZEROPAD == ('0' - ' '));
-static_assert(SMALL == ' ');
+static_assert(SMALL == ('a' ^ 'A'));
 
 enum format_type {
        FORMAT_TYPE_NONE, /* Just a string part */
This page took 0.056294 seconds and 4 git commands to generate.