From: Alejandro Colomar Date: Sat, 31 Aug 2024 09:37:40 +0000 (+0200) Subject: src/: Invert logic to improve readability X-Git-Tag: 4.17.0-rc1~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0663c91f80a6bc78275e9228a133f07836eeba4b;p=thirdparty%2Fshadow.git src/: Invert logic to improve readability And remove the (now) redundant comments. Signed-off-by: Alejandro Colomar --- diff --git a/src/groupadd.c b/src/groupadd.c index 6db991a84..d38c4ddfc 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -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; } /* diff --git a/src/groupmod.c b/src/groupmod.c index 15a673c5d..0c0e29a60 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -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; } /*