summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nandana Dutt <nandana@google.com> 2019-01-11 06:09:10 -0800
committer android-build-merger <android-build-merger@google.com> 2019-01-11 06:09:10 -0800
commita319fb22fe9b910b4a119a63e90b6b3be949a779 (patch)
tree10d126ae2804cdd9dc22bf37416a06460ae3f1ce
parent2172a6cb475ac558625e4b93256654fd5bbecf78 (diff)
parentee7e30bc92edffc90e2374a7f6e6fa7d50d3ee3f (diff)
Merge "Simplify the exit conditions for dumpstate"
am: ee7e30bc92 Change-Id: Ie1e1d5fc0df3e6f9af9c4cb7980504b80e3675d9
-rw-r--r--cmds/dumpstate/dumpstate.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 70154e8db3..ffb5c95714 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1695,7 +1695,7 @@ void Dumpstate::DumpstateBoard() {
printf("*** See dumpstate-board.txt entry ***\n");
}
-static void ShowUsageAndExit(int exit_code = 1) {
+static void ShowUsage() {
fprintf(stderr,
"usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file] [-d] [-p] "
"[-z]] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n"
@@ -1715,12 +1715,6 @@ static void ShowUsageAndExit(int exit_code = 1) {
" -R: take bugreport in remote mode (requires -o, -z, -d and -B, "
"shouldn't be used with -P)\n"
" -v: prints the dumpstate header and exit\n");
- exit(exit_code);
-}
-
-static void ExitOnInvalidArgs() {
- fprintf(stderr, "invalid combination of args\n");
- ShowUsageAndExit();
}
static void register_sig_handler() {
@@ -2517,17 +2511,18 @@ int run_main(int argc, char* argv[]) {
switch (status) {
case Dumpstate::RunStatus::OK:
- return 0;
- // TODO(b/111441001): Exit directly in the following cases.
+ exit(0);
case Dumpstate::RunStatus::HELP:
- ShowUsageAndExit(0 /* exit code */);
- break;
+ ShowUsage();
+ exit(0);
case Dumpstate::RunStatus::INVALID_INPUT:
- ExitOnInvalidArgs();
- break;
+ fprintf(stderr, "Invalid combination of args\n");
+ ShowUsage();
+ exit(1);
case Dumpstate::RunStatus::ERROR:
- exit(-1);
- break;
+ exit(2);
+ default:
+ fprintf(stderr, "Unknown status: %d\n", status);
+ exit(2);
}
- return 0;
}