]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/fields.c: valid_field(): Clarify comments
authorAlejandro Colomar <alx@kernel.org>
Wed, 11 Dec 2024 22:03:54 +0000 (23:03 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 3 Jun 2025 14:04:01 +0000 (09:04 -0500)
And apply minor style changes.

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

index 67c90b91cc4aa8d8b15898b28699f6aab33db3f1..b32ca4662af5c6cd3dfe9737a1647e81d5d7bf74 100644 (file)
 /*
  * valid_field - insure that a field contains all legal characters
  *
- * The supplied field is scanned for non-printable and other illegal
- * characters.
- *  + -1 is returned if an illegal or control character is present.
- *  +  1 is returned if no illegal or control characters are present,
- *       but the field contains a non-printable character.
- *  +  0 is returned otherwise.
+ * Return:
+ *     -1      Illegal or control characters are present.
+ *     1       Non-ASCII characters are present.
+ *     0       All chatacters are legal and ASCII.
  */
 int
 valid_field_(const char *field, const char *illegal)
 {
-       if (NULL == field) {
+       if (NULL == field)
                return -1;
-       }
 
        if (strpbrk(field, illegal))
                return -1;
@@ -50,7 +47,7 @@ valid_field_(const char *field, const char *illegal)
        if (streq(field, ""))
                return 0;
 
-       return 1;
+       return 1;  // !ASCII
 }
 
 /*