Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee7e30bc authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Simplify the exit conditions for dumpstate"

parents 68f8a18e 12ae14a5
Loading
Loading
Loading
Loading
+11 −16
Original line number Original line Diff line number Diff line
@@ -1695,7 +1695,7 @@ void Dumpstate::DumpstateBoard() {
    printf("*** See dumpstate-board.txt entry ***\n");
    printf("*** See dumpstate-board.txt entry ***\n");
}
}


static void ShowUsageAndExit(int exit_code = 1) {
static void ShowUsage() {
    fprintf(stderr,
    fprintf(stderr,
            "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file] [-d] [-p] "
            "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file] [-d] [-p] "
            "[-z]] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n"
            "[-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, "
            "  -R: take bugreport in remote mode (requires -o, -z, -d and -B, "
            "shouldn't be used with -P)\n"
            "shouldn't be used with -P)\n"
            "  -v: prints the dumpstate header and exit\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() {
static void register_sig_handler() {
@@ -2517,17 +2511,18 @@ int run_main(int argc, char* argv[]) {


    switch (status) {
    switch (status) {
        case Dumpstate::RunStatus::OK:
        case Dumpstate::RunStatus::OK:
            return 0;
            exit(0);
            // TODO(b/111441001): Exit directly in the following cases.
        case Dumpstate::RunStatus::HELP:
        case Dumpstate::RunStatus::HELP:
            ShowUsageAndExit(0 /* exit code */);
            ShowUsage();
            break;
            exit(0);
        case Dumpstate::RunStatus::INVALID_INPUT:
        case Dumpstate::RunStatus::INVALID_INPUT:
            ExitOnInvalidArgs();
            fprintf(stderr, "Invalid combination of args\n");
            break;
            ShowUsage();
            exit(1);
        case Dumpstate::RunStatus::ERROR:
        case Dumpstate::RunStatus::ERROR:
            exit(-1);
            exit(2);
            break;
        default:
            fprintf(stderr, "Unknown status: %d\n", status);
            exit(2);
    }
    }
    return 0;
}
}