diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-07-29 17:45:19 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-07-30 15:58:09 +0200 |
commit | 777003365a87aa6656938d0ecca9d54887fefab9 (patch) | |
tree | f158c43048535fb6556a4b6c19c47e3a35e518a8 | |
parent | macro: relax CONST_MAX() type check a tiny bit (diff) | |
download | systemd-777003365a87aa6656938d0ecca9d54887fefab9.tar.xz systemd-777003365a87aa6656938d0ecca9d54887fefab9.zip |
macro: sizeof() returns size_t, and that's good
Now that CONST_MAX() is a bit more foregiving, let's stick to the native
return type of sizeof() everywhere, which is size_t, instead of casting
to "unsigned", so that on the common archs we don't unnecessarily lose
the upper 32bits.
This semi-reverts d3e40294572512810c9329933a488619e7ce22fd.
-rw-r--r-- | src/basic/macro.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h index a8476184c2..829d8dc8a7 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -214,7 +214,7 @@ static inline size_t GREEDY_ALLOC_ROUND_UP(size_t l) { * Contrary to strlen(), this is a constant expression. * @x: a string literal. */ -#define STRLEN(x) ((unsigned) sizeof(""x"") - 1) +#define STRLEN(x) (sizeof(""x"") - 1U) /* * container_of - cast a member of a structure out to the containing structure @@ -345,7 +345,7 @@ static inline int __coverity_check_and_return__(int condition) { (2U+(sizeof(type) <= 1 ? 3U : \ sizeof(type) <= 2 ? 5U : \ sizeof(type) <= 4 ? 10U : \ - sizeof(type) <= 8 ? 20U : (unsigned) sizeof(int[-2*(sizeof(type) > 8)]))) + sizeof(type) <= 8 ? 20U : sizeof(int[-2*(sizeof(type) > 8)]))) #define DECIMAL_STR_WIDTH(x) \ ({ \ |