]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/sizeof.h: Make sure STRLEN() only accepts string literals
authorAlejandro Colomar <alx@kernel.org>
Sun, 25 May 2025 13:04:25 +0000 (15:04 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 26 May 2025 16:24:08 +0000 (18:24 +0200)
Link: <https://stackoverflow.com/a/79369560/6872717>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/sizeof.h

index ed0fc155dbe9100b0de606cb108d962fca9429ef..6051b7777d2478ad2689f9c02e587628a9a5a791 100644 (file)
@@ -21,7 +21,7 @@
 #define WIDTHOF(x)           (sizeof(x) * CHAR_BIT)
 #define SIZEOF_ARRAY(a)      (sizeof(a) + must_be_array(a))
 #define NITEMS(a)            (SIZEOF_ARRAY((a)) / sizeof((a)[0]))
-#define STRLEN(s)            (NITEMS(s) - 1)
+#define STRLEN(s)            (NITEMS("" s "") - 1)
 
 
 #endif  // include guard