Add STRLEN(): a constexpr strlen(3) for string literals

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
Alejandro Colomar 2023-03-13 01:51:12 +01:00 committed by Iker Pedrosa
parent 03af2940f7
commit 664d361fa5
1 changed files with 1 additions and 0 deletions

View File

@ -171,6 +171,7 @@ static inline void memzero(void *ptr, size_t size)
#define WIDTHOF(x) (sizeof(x) * CHAR_BIT)
#define NITEMS(arr) (sizeof((arr)) / sizeof((arr)[0]))
#define STRLEN(s) (NITEMS(s) - 1)
/* Copy string pointed by B to array A with size checking. It was originally
in lmain.c but is _very_ useful elsewhere. Some setuid root programs with