exit() calls are very bad. GUI's and payload don't like it, so remove it for easier flashrom usage across projects.
P.S. currently return values are the same as vere to exit calls, so if you have a clue what these should be please tell it now.
Signed-off-by: Tadas Slotkus devtadas@gmail.com --- cli_classic.c | 55 ++++++++++++++++++++++++++----------------------------- 1 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/cli_classic.c b/cli_classic.c index c6fb379..43b435f 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -93,7 +93,6 @@ static void cli_classic_usage(const char *name) static void cli_classic_abort_usage(void) { printf("Please run "flashrom --help" for usage info.\n"); - exit(1); }
int main(int argc, char *argv[]) @@ -142,7 +141,7 @@ int main(int argc, char *argv[]) print_banner();
if (selfcheck()) - exit(1); + return 1;
setbuf(stdout, NULL); /* FIXME: Delay all operation_specified checks until after command @@ -155,7 +154,7 @@ int main(int argc, char *argv[]) if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } filename = strdup(optarg); read_it = 1; @@ -164,7 +163,7 @@ int main(int argc, char *argv[]) if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } filename = strdup(optarg); write_it = 1; @@ -174,12 +173,12 @@ int main(int argc, char *argv[]) if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } if (dont_verify_it) { fprintf(stderr, "--verify and --noverify are" "mutually exclusive. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } filename = strdup(optarg); verify_it = 1; @@ -188,7 +187,7 @@ int main(int argc, char *argv[]) if (verify_it) { fprintf(stderr, "--verify and --noverify are" "mutually exclusive. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } dont_verify_it = 1; break; @@ -202,7 +201,7 @@ int main(int argc, char *argv[]) if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } erase_it = 1; break; @@ -214,7 +213,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error: Internal programmer support " "was not compiled in and --mainboard only\n" "applies to the internal programmer. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; #endif break; case 'f': @@ -222,8 +221,9 @@ int main(int argc, char *argv[]) break; case 'l': tempstr = strdup(optarg); - if (read_romlayout(tempstr)) - cli_classic_abort_usage(); + if (read_romlayout(tempstr)) { + cli_classic_abort_usage(); return 1; + } break; case 'i': /* FIXME: -l has to be specified before -i. */ @@ -232,14 +232,14 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error: image %s not found in " "layout file or -i specified before " "-l\n", tempstr); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } break; case 'L': if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } list_supported = 1; break; @@ -248,13 +248,13 @@ int main(int argc, char *argv[]) if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } list_supported_wiki = 1; #else fprintf(stderr, "Error: Wiki output was not compiled " "in. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; #endif break; case 'p': @@ -286,7 +286,7 @@ int main(int argc, char *argv[]) if (programmer == PROGRAMMER_INVALID) { fprintf(stderr, "Error: Unknown programmer " "%s.\n", optarg); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } break; case 'R': @@ -294,41 +294,38 @@ int main(int argc, char *argv[]) if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } - exit(0); - break; + return 0; case 'h': if (++operation_specified > 1) { fprintf(stderr, "More than one operation " "specified. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } cli_classic_usage(argv[0]); - exit(0); - break; + return 0; default: - cli_classic_abort_usage(); - break; + cli_classic_abort_usage(); return 1; } }
if (optind < argc) { fprintf(stderr, "Error: Extra parameter found.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; }
/* FIXME: Print the actions flashrom will take. */
if (list_supported) { print_supported(); - exit(0); + return 0; }
#if CONFIG_PRINT_WIKI == 1 if (list_supported_wiki) { print_supported_wiki(); - exit(0); + return 0; } #endif
@@ -336,7 +333,7 @@ int main(int argc, char *argv[]) if ((programmer != PROGRAMMER_INTERNAL) && (lb_part || lb_vendor)) { fprintf(stderr, "Error: --mainboard requires the internal " "programmer. Aborting.\n"); - cli_classic_abort_usage(); + cli_classic_abort_usage(); return 1; } #endif
@@ -349,7 +346,7 @@ int main(int argc, char *argv[]) chip_to_probe); printf("Run flashrom -L to view the hardware supported " "in this flashrom version.\n"); - exit(1); + return 1; } /* Clean up after the check. */ flash = NULL;