summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2012-12-12 10:36:32 +0100
committerKarel Zak2012-12-12 10:36:32 +0100
commit97da60c64e231bdfba163e23cbbe9e52c1550d06 (patch)
tree29ae041f7b253e097723dc954773eafebb56c542
parenttests: unset *_DEBUG variables (diff)
downloadkernel-qcow2-util-linux-97da60c64e231bdfba163e23cbbe9e52c1550d06.tar.gz
kernel-qcow2-util-linux-97da60c64e231bdfba163e23cbbe9e52c1550d06.tar.xz
kernel-qcow2-util-linux-97da60c64e231bdfba163e23cbbe9e52c1550d06.zip
chfn: clean up exit status
The old version in some cases (but not always) returns -1 (255) on error. It seems better to cleanup the code and don't return internal return codes by exit(). Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--login-utils/chfn.12
-rw-r--r--login-utils/chfn.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/login-utils/chfn.1 b/login-utils/chfn.1
index 532940888..5f87ad713 100644
--- a/login-utils/chfn.1
+++ b/login-utils/chfn.1
@@ -72,6 +72,8 @@ Print a usage message and exit.
.TP
.B "-v, \-\-version"
Print version information and exit.
+.SH "EXIT STATUS"
+Returns 0 if operation was successful, 1 if operation failed or command syntax was not valid.
.SH "SEE ALSO"
.BR finger (1),
.BR passwd (5)
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index 02014c7ce..a86f380c0 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -91,7 +91,6 @@ int main(int argc, char **argv)
uid_t uid;
struct finfo oldf, newf;
int interactive;
- int status;
sanitize_env();
setlocale(LC_ALL, ""); /* both for messages and for iscntrl() below */
@@ -196,8 +195,8 @@ int main(int argc, char **argv)
printf(_("Finger information not changed.\n"));
return EXIT_SUCCESS;
}
- status = save_new_data(&oldf);
- return status;
+
+ return save_new_data(&oldf) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
/*
@@ -262,8 +261,8 @@ static int parse_argv(int argc, char *argv[], struct finfo *pinfo)
default:
usage(stderr);
}
- if (status < 0)
- exit(status);
+ if (status != 0)
+ exit(EXIT_FAILURE);
}
/* done parsing arguments. check for a username. */
if (optind < argc) {
@@ -271,7 +270,7 @@ static int parse_argv(int argc, char *argv[], struct finfo *pinfo)
usage(stderr);
pinfo->username = argv[optind];
}
- return (!info_given);
+ return !info_given;
}
/*