]> granicus.if.org Git - shadow/commitdiff
Avoid implict brackets.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 28 Dec 2007 10:12:09 +0000 (10:12 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 28 Dec 2007 10:12:09 +0000 (10:12 +0000)
ChangeLog
src/groupadd.c

index 251902b3aaf3b7d3a7f7ba25e2a0641c62b36e15..915996d090a5cb75df5466cebe1e13f1eb50061a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
        * src/groupadd.c (fail_exit): When compiled without AUDIT support, if
        the return code was E_SUCCESS, fail_exit() wouldn't have exited. Fix
        the scope of #idef WITH_AUDIT.
+       * src/groupadd.c: Avoid implicit brackets.
 
 2007-12-27  Nicolas François  <nicolas.francois@centraliens.net>
 
index 8b47653c99ddf56a53506cc51880270a81975cb9..9e881d79ae193a56ca415b9c2448b52f88ff59df 100644 (file)
@@ -206,8 +206,9 @@ static void find_new_gid (void)
         * one already.
         */
 
-       if (!gflg)
+       if (!gflg) {
                group_id = gid_min;
+       }
 
        /*
         * Search the entire group file, either looking for this GID (if the
@@ -224,7 +225,7 @@ static void find_new_gid (void)
                                 Prog, group_name);
                        fail_exit (E_NAME_IN_USE);
                }
-               if (gflg && group_id == grp->gr_gid) {
+               if (gflg && (group_id == grp->gr_gid)) {
                        if (fflg) {
                                /* turn off -g and search again */
                                gflg = 0;
@@ -235,17 +236,18 @@ static void find_new_gid (void)
                                 Prog, (unsigned int) group_id);
                        fail_exit (E_GID_IN_USE);
                }
-               if (!gflg && grp->gr_gid >= group_id) {
+               if (!gflg && (grp->gr_gid >= group_id)) {
                        if (grp->gr_gid > gid_max)
                                continue;
                        group_id = grp->gr_gid + 1;
                }
        }
-       if (!gflg && group_id == gid_max + 1) {
+       if (!gflg && (group_id == (gid_max + 1))) {
                for (group_id = gid_min; group_id < gid_max; group_id++) {
                        /* local, no need for xgetgrgid */
-                       if (!getgrgid (group_id))
+                       if (!getgrgid (group_id)) {
                                break;
+                       }
                }
                if (group_id == gid_max) {
                        fprintf (stderr, _("%s: can't get unique GID\n"), Prog);
@@ -262,8 +264,9 @@ static void find_new_gid (void)
  */
 static void check_new_name (void)
 {
-       if (check_group_name (group_name))
+       if (check_group_name (group_name)) {
                return;
+       }
 
        /*
         * All invalid group names land here.
@@ -294,8 +297,9 @@ static void close_files (void)
                         _("%s: cannot rewrite shadow group file\n"), Prog);
                fail_exit (E_GRP_UPDATE);
        }
-       if (is_shadow_grp)
+       if (is_shadow_grp) {
                sgr_unlock ();
+       }
 #endif                         /* SHADOWGRP */
 }
 
@@ -343,13 +347,15 @@ static void fail_exit (int code)
 {
        (void) gr_unlock ();
 #ifdef SHADOWGRP
-       if (is_shadow_grp)
+       if (is_shadow_grp) {
                sgr_unlock ();
+       }
 #endif
 #ifdef WITH_AUDIT
-       if (code != E_SUCCESS)
+       if (code != E_SUCCESS) {
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding group",
                              group_name, -1, 0);
+       }
 #endif
        exit (code);
 }
@@ -363,7 +369,7 @@ static gid_t get_gid (const char *gidstr)
        char *errptr;
 
        val = strtol (gidstr, &errptr, 10);
-       if (*errptr || errno == ERANGE || val < 0) {
+       if (('\0' != *errptr) || (errno == ERANGE) || (val < 0)) {
                fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog,
                         gidstr);
                exit (E_BAD_ARG);
@@ -449,8 +455,9 @@ int main (int argc, char **argv)
                                }
                                /* terminate name, point to value */
                                *cp++ = '\0';
-                               if (putdef_str (optarg, cp) < 0)
+                               if (putdef_str (optarg, cp) < 0) {
                                        exit (E_BAD_ARG);
+                               }
                                break;
                        case 'o':
                                oflg++;
@@ -461,11 +468,13 @@ int main (int argc, char **argv)
                }
        }
 
-       if (oflg && !gflg)
+       if (oflg && !gflg) {
                usage ();
+       }
 
-       if (optind != argc - 1)
+       if (optind != argc - 1) {
                usage ();
+       }
 
        group_name = argv[argc - 1];
        check_new_name ();
@@ -531,8 +540,9 @@ int main (int argc, char **argv)
         */
        open_files ();
 
-       if (!gflg || !oflg)
+       if (!gflg || !oflg) {
                find_new_gid ();
+       }
 
        grp_update ();
        close_files ();
@@ -540,9 +550,11 @@ int main (int argc, char **argv)
        nscd_flush_cache ("group");
 
 #ifdef USE_PAM
-       if (retval == PAM_SUCCESS)
+       if (retval == PAM_SUCCESS) {
                pam_end (pamh, PAM_SUCCESS);
+       }
 #endif                         /* USE_PAM */
        exit (E_SUCCESS);
        /* NOT REACHED */
 }
+