diff options
author | Jeff Layton <jlayton@samba.org> | 2012-01-17 14:43:24 -0500 |
---|---|---|
committer | Jeff Layton <jlayton@samba.org> | 2012-01-17 14:43:24 -0500 |
commit | c00f56c895b184a5380412f047b4251f88d0f0b8 (patch) | |
tree | ef5956824565fa7218ad9f45527df590492bed35 | |
parent | 1578af7afadf0c9cb132ea9224c877dced1f0114 (diff) | |
download | cifs-utils-c00f56c895b184a5380412f047b4251f88d0f0b8.tar.gz cifs-utils-c00f56c895b184a5380412f047b4251f88d0f0b8.tar.bz2 cifs-utils-c00f56c895b184a5380412f047b4251f88d0f0b8.zip |
cifscreds: make usage use "return" and have callers return
...banish the use of exit(), which may be helpful in the future in
the event that we eventually move some of this code into a library.
Signed-off-by: Jeff Layton <jlayton@samba.org>
-rw-r--r-- | cifscreds.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/cifscreds.c b/cifscreds.c index b6c1fb6..3ed15f2 100644 --- a/cifscreds.c +++ b/cifscreds.c @@ -70,7 +70,8 @@ struct command commands[] = { }; /* display usage information */ -static void usage(void) +static int +usage(void) { struct command *cmd; @@ -80,7 +81,7 @@ static void usage(void) cmd->name, cmd->format); fprintf(stderr, "\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } /* search a specific key in keyring */ @@ -217,7 +218,7 @@ static int cifscreds_add(int argc, char *argv[]) int ret; if (argc != 4) - usage(); + return usage(); ret = resolve_host(argv[2], addrstr); switch (ret) { @@ -312,7 +313,7 @@ static int cifscreds_clear(int argc, char *argv[]) int ret, count = 0, errors = 0; if (argc != 4) - usage(); + return usage(); ret = resolve_host(argv[2], addrstr); switch (ret) { @@ -380,7 +381,7 @@ static int cifscreds_clearall(int argc, char *argv[] __attribute__ ((unused))) int count = 0, errors = 0; if (argc != 2) - usage(); + return usage(); /* * search for all program's credentials stashed in session keyring @@ -420,7 +421,7 @@ static int cifscreds_update(int argc, char *argv[]) int ret, id, count = 0; if (argc != 4) - usage(); + return usage(); ret = resolve_host(argv[2], addrstr); switch (ret) { @@ -491,7 +492,7 @@ int main(int argc, char **argv) thisprogram = THIS_PROGRAM_NAME; if (argc == 1) - usage(); + return usage(); /* find the best fit command */ best = NULL; @@ -510,7 +511,7 @@ int main(int argc, char **argv) /* partial match */ if (best) { fprintf(stderr, "Ambiguous command\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } best = cmd; @@ -518,8 +519,8 @@ int main(int argc, char **argv) if (!best) { fprintf(stderr, "Unknown command\n"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } - exit(best->action(argc, argv)); + return best->action(argc, argv); } |