src/: Invert logic to improve readability

And remove the (now) redundant comments.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-08-31 11:37:40 +02:00
committed by Serge Hallyn
parent 1c127bd173
commit 0663c91f80
2 changed files with 23 additions and 32 deletions
+8 -11
View 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;
if (!is_valid_group_name(group_name)) {
fprintf(stderr, _("%s: '%s' is not a valid group name\n"),
Prog, group_name);
exit(E_BAD_ARG);
}
/*
* All invalid group names land here.
*/
fprintf (stderr, _("%s: '%s' is not a valid group name\n"),
Prog, group_name);
exit (E_BAD_ARG);
return;
}
/*
+15 -21
View 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;
}
/*