]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Treat strpbrk(3)'s return value as a boolean
authorAlejandro Colomar <alx@kernel.org>
Wed, 1 Jan 2025 00:04:38 +0000 (01:04 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 27 May 2025 01:04:27 +0000 (20:04 -0500)
with the meaning "a character was found".

strpbrk(3) is just like strchr(3), but searches for multiple characters.
Both functions have a boolean-like return value, which evaluates to true
if a character was found.

A better name for strpbrk(3) would have been strchrs().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/fields.c
lib/setupenv.c

index 9e08adadff3b02515d99946fbec217738dad7abe..ef828374154b3a7b0af0f800dd2565cd9788ee26 100644 (file)
@@ -43,7 +43,7 @@ int valid_field (const char *field, const char *illegal)
 
        /* For each character of field, search if it appears in the list
         * of illegal characters. */
-       if (illegal && NULL != strpbrk (field, illegal)) {
+       if (illegal && strpbrk(field, illegal)) {
                return -1;
        }
 
index 1bc3da314ca835bdac2022c0b0593431a17153b1..29e2aac3cbe72e664c1dd08df704d1414535704b 100644 (file)
@@ -73,7 +73,7 @@ static void read_env_file (const char *filename)
                val = stpsep(cp, "=");
                if (val == NULL)
                        continue;
-               if (strpbrk(name, " \t") != NULL)
+               if (strpbrk(name, " \t"))
                        continue;
 #if 0                          /* XXX untested, and needs rewrite with fewer goto's :-) */
 /*