]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/: Invert logic to improve readability
authorAlejandro Colomar <alx@kernel.org>
Sat, 31 Aug 2024 09:37:40 +0000 (11:37 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sun, 1 Sep 2024 13:17:11 +0000 (08:17 -0500)
And remove the (now) redundant comments.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/groupadd.c
src/groupmod.c

index 6db991a8403b84fdb2dc46e23cd996daf9c07081..d38c4ddfcf2ab8c52c05edd608de5848feea38db 100644 (file)
@@ -236,20 +236,17 @@ static void grp_update (void)
  *     check_new_name() insures that the new name doesn't contain any
  *     illegal characters.
  */
-static void check_new_name (void)
+static void
+check_new_name(void)
 {
-       if (is_valid_group_name (group_name)) {
-               return;
-       }
-
-       /*
-        * All invalid group names land here.
-        */
+       if (!is_valid_group_name(group_name)) {
+               fprintf(stderr, _("%s: '%s' is not a valid group name\n"),
+                       Prog, group_name);
 
-       fprintf (stderr, _("%s: '%s' is not a valid group name\n"),
-                Prog, group_name);
+               exit(E_BAD_ARG);
+       }
 
-       exit (E_BAD_ARG);
+       return;
 }
 
 /*
index 15a673c5d62a52a87f902411e9eac19d331ab466..0c0e29a600998a7d5ecf8f67cb29e254f7dc21b2 100644 (file)
@@ -351,7 +351,8 @@ static void check_new_gid (void)
  *     check_new_name() insures that the new name does not exist already.
  *     You can't have the same name twice, period.
  */
-static void check_new_name (void)
+static void
+check_new_name(void)
 {
        /*
         * Make sure they are actually changing the name.
@@ -361,29 +362,22 @@ static void check_new_name (void)
                return;
        }
 
-       if (is_valid_group_name (group_newname)) {
-
-               /*
-                * If the entry is found, too bad.
-                */
-               /* local, no need for xgetgrnam */
-               if (prefix_getgrnam (group_newname) != NULL) {
-                       fprintf (stderr,
-                                _("%s: group '%s' already exists\n"),
-                                Prog, group_newname);
-                       exit (E_NAME_IN_USE);
-               }
-               return;
+       if (!is_valid_group_name(group_newname)) {
+               fprintf(stderr,
+                       _("%s: invalid group name '%s'\n"),
+                       Prog, group_newname);
+               exit(E_BAD_ARG);
        }
 
-       /*
-        * All invalid group names land here.
-        */
+       /* local, no need for xgetgrnam */
+       if (prefix_getgrnam(group_newname) != NULL) {
+               fprintf(stderr,
+                       _("%s: group '%s' already exists\n"),
+                       Prog, group_newname);
+               exit(E_NAME_IN_USE);
+       }
 
-       fprintf (stderr,
-                _("%s: invalid group name '%s'\n"),
-                Prog, group_newname);
-       exit (E_BAD_ARG);
+       return;
 }
 
 /*