]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/strchr/: strnul(): Simplify implementation
authorAlejandro Colomar <alx@kernel.org>
Thu, 19 Feb 2026 01:01:09 +0000 (02:01 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 28 Feb 2026 03:03:40 +0000 (21:03 -0600)
This avoids an __auto_type local variable, and a GNU statement
expression.

Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/strchr/strnul.h

index 4cb3b2ca6a7e5f76c57ffda7b7be4fdf9a900a14..f03d36e9fb94a1eceb942b0f05a855c54ad4d29e 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
 
 #include <string.h>
 
-#include "attr.h"
 
-
-// string null-byte
-// Similar to strlen(3), but return a pointer instead of an offset.
-#define strnul(s)                                                             \
-({                                                                            \
-       __auto_type  s_ = s;                                                  \
-                                                                             \
-       s_ + strlen(s_);                                                      \
-})
+// strnul - string null-byte
+#define strnul(s)  strchr(s, '\0')
 
 
 #endif  // include guard