From 53fb7e41b122f10320c80cdd9591d97b093214bb Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Mon, 20 Feb 2017 14:06:16 +0100 Subject: capinfos: use single exit point. Change-Id: Ib1b556c07ec3e1f788c48038ed6bb0ae6af5cb7d Reviewed-on: https://code.wireshark.org/review/20196 Petri-Dish: Dario Lombardo Reviewed-by: Michael Mann --- capinfos.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'capinfos.c') diff --git a/capinfos.c b/capinfos.c index c548f43f57..896728aea2 100644 --- a/capinfos.c +++ b/capinfos.c @@ -95,6 +95,9 @@ #include #endif /* _WIN32 */ +#define INVALID_OPTION 1 +#define BAD_FLAG 1 + /* * By default capinfos now continues processing * the next filename if and when wiretap detects @@ -1388,7 +1391,7 @@ main(int argc, char *argv[]) int err; gchar *err_info; int opt; - int overall_error_status; + int overall_error_status = EXIT_SUCCESS; static const struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, @@ -1619,7 +1622,7 @@ main(int argc, char *argv[]) "See https://www.wireshark.org for more information.\n", get_ws_vcs_version_info()); print_usage(stdout); - exit(0); + goto exit; break; case 'v': @@ -1628,19 +1631,21 @@ main(int argc, char *argv[]) show_version("Capinfos (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); - exit(0); + goto exit; break; case '?': /* Bad flag - print usage message */ print_usage(stderr); - exit(1); + overall_error_status = BAD_FLAG; + goto exit; break; } } if ((argc - optind) < 1) { print_usage(stderr); - exit(1); + overall_error_status = INVALID_OPTION; + goto exit; } if (!long_report && table_report_header) { -- cgit v1.2.1