* lib/sgetpwent.c: Avoid implicit conversion of pointers / chars to booleans.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 26 May 2008 09:15:02 +0000 (09:15 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 26 May 2008 09:15:02 +0000 (09:15 +0000)
* lib/sgetpwent.c: Add brackets and parenthesis.
* lib/sgetpwent.c: Return NULL instead of 0.

ChangeLog
lib/sgetpwent.c

index 0da5c74f436fd527f18f1834f1f96137cf1c7f78..1274326d0c719e5cdfc1eba9dbed0fc50a1a2da6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * lib/sgetpwent.c: Avoid implicit conversion of pointers / chars to
+       booleans.
+       * lib/sgetpwent.c: Add brackets and parenthesis.
+       * lib/sgetpwent.c: Return NULL instead of 0.
+
+
 2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/getdate.y: abbrev is a bool.
index e9061e363a611608d0120e6b66051161bbfd0b91..3648e60c4e8979a47a45dcc81cbd18250b20d9be 100644 (file)
@@ -77,15 +77,18 @@ struct passwd *sgetpwent (const char *buf)
         * field.  The fields are converted into NUL terminated strings.
         */
 
-       for (cp = pwdbuf, i = 0; i < NFIELDS && cp; i++) {
+       for (cp = pwdbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++) {
                fields[i] = cp;
-               while (*cp && *cp != ':')
-                       ++cp;
+               while (('\0' != *cp) && (':' != *cp)) {
+                       cp++;
+               }
 
-               if (*cp)
-                       *cp++ = '\0';
-               else
-                       cp = 0;
+               if ('\0' != *cp) {
+                       *cp = '\0';
+                       cp++;
+               } else {
+                       cp = NULL;
+               }
        }
 
        /*
@@ -94,7 +97,7 @@ struct passwd *sgetpwent (const char *buf)
         */
 
        if (i != NFIELDS || *fields[2] == '\0' || *fields[3] == '\0')
-               return 0;
+               return NULL;
 
        /*
         * Each of the fields is converted the appropriate data type
@@ -106,12 +109,12 @@ struct passwd *sgetpwent (const char *buf)
        pwent.pw_name = fields[0];
        pwent.pw_passwd = fields[1];
        if (fields[2][0] == '\0' ||
-           ((pwent.pw_uid = strtol (fields[2], &ep, 10)) == 0 && *ep)) {
-               return 0;
+           ((pwent.pw_uid = strtol (fields[2], &ep, 10)) == 0 && ('\0' != *ep))) {
+               return NULL;
        }
        if (fields[3][0] == '\0' ||
-           ((pwent.pw_gid = strtol (fields[3], &ep, 10)) == 0 && *ep)) {
-               return 0;
+           ((pwent.pw_gid = strtol (fields[3], &ep, 10)) == 0 && ('\0' != *ep))) {
+               return NULL;
        }
        pwent.pw_gecos = fields[4];
        pwent.pw_dir = fields[5];
@@ -119,3 +122,4 @@ struct passwd *sgetpwent (const char *buf)
 
        return &pwent;
 }
+