The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v1 1/1] lib/vsprintf.c: Amend static asserts for format specifier flags
@ 2021-10-26 14:03 Andy Shevchenko
  2021-10-27 13:34 ` Petr Mladek
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2021-10-26 14:03 UTC (permalink / raw)
  To: Petr Mladek, linux-kernel
  Cc: Steven Rostedt, Sergey Senozhatsky, Andy Shevchenko,
	Rasmus Villemoes

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>
---
 lib/vsprintf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index f15a49ff6fab..ddfb3d836f38 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -407,8 +407,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 */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-27 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-26 14:03 [PATCH v1 1/1] lib/vsprintf.c: Amend static asserts for format specifier flags Andy Shevchenko
2021-10-27 13:34 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox