History

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).

Andy Shevchenko committed 5 years ago

Commit 24a1dff1 parent c15b5fc1 file · +2 −1Browse files

Unified · Split

lib/vsprintf.c+2−1
@@ -408,8 +408,9 @@ int num_to_str(char *buf, int size, unsigned long long num, unsigned int width) · 407 unmodified lines
408#define SMALL 32 /* use lowercase in hex (must be 32 == 0x20) */408#define SMALL 32 /* use lowercase in hex (must be 32 == 0x20) */
409#define SPECIAL 64 /* prefix hex with "0x", octal with "0" */409#define SPECIAL 64 /* prefix hex with "0x", octal with "0" */
410 410
411static_assert(SIGN == 1);
411static_assert(ZEROPAD == ('0' - ' '));412static_assert(ZEROPAD == ('0' - ' '));
412static_assert(SMALL == ' ');413static_assert(SMALL == ('a' ^ 'A'));
413 414
414enum format_type {415enum format_type {
415 FORMAT_TYPE_NONE, /* Just a string part */416 FORMAT_TYPE_NONE, /* Just a string part */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t