summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-10-26 17:03:56 +0300
committerPetr Mladek <pmladek@suse.com>2021-10-27 15:13:47 +0200
commit24a1dffbecafeb00d8830985eb7a318e37aabc4e (patch)
treebca18b9e0ffa9bcbf157a4ce69cf79844beaf438 /lib
parentc15b5fc054c3d6c97e953617605235c5cb8ce979 (diff)
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 <andriy.shevchenko@linux.intel.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20211026140356.45610-1-andriy.shevchenko@linux.intel.com
Diffstat (limited to 'lib')
-rw-r--r--lib/vsprintf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 26c83943748a..1173930ed9d3 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -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 */