summaryrefslogtreecommitdiff
path: root/sharkd.c
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2017-02-03 23:06:35 +0100
committerMichael Mann <mmann78@netscape.net>2017-02-08 14:49:37 +0000
commitbfe07161a5db3db7c71ecc3a8c55a791e830e107 (patch)
treea6b62c00fc4031eeb98a952a6f6e522b88b33c59 /sharkd.c
parent70381f774c1f8b272b18f9a5403a02e6bb05125d (diff)
downloadwireshark-bfe07161a5db3db7c71ecc3a8c55a791e830e107.tar.gz
sharkd: make the way it returns more similar to other apps.
The clean_exit block allows deallocation of memory on exit. Change-Id: I52078f0e4e851b6aa5f34cbbd15eba0a4f37cae0 Reviewed-on: https://code.wireshark.org/review/19940 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'sharkd.c')
-rw-r--r--sharkd.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sharkd.c b/sharkd.c
index 26ac51ed45..964ea92a05 100644
--- a/sharkd.c
+++ b/sharkd.c
@@ -77,6 +77,9 @@
#include "sharkd.h"
+#define INIT_FAILED 1
+#define EPAN_INIT_FAIL 2
+
static guint32 cum_bytes;
static const frame_data *ref;
static frame_data ref_frame;
@@ -130,6 +133,7 @@ main(int argc, char *argv[])
int dp_open_errno, dp_read_errno;
int cf_open_errno;
e_prefs *prefs_p;
+ int ret = EXIT_SUCCESS;
cmdarg_err_init(failure_message, failure_message_cont);
@@ -170,7 +174,8 @@ main(int argc, char *argv[])
if (sharkd_init(argc, argv) < 0)
{
printf("cannot initialize sharkd\n");
- return 1;
+ ret = INIT_FAILED;
+ goto clean_exit;
}
init_report_err(failure_message, open_failure_message, read_failure_message,
@@ -199,8 +204,10 @@ main(int argc, char *argv[])
dissectors, and we must do it before we read the preferences, in
case any dissectors register preferences. */
if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL,
- NULL))
- return 2;
+ NULL)) {
+ ret = EPAN_INIT_FAIL;
+ goto clean_exit;
+ }
/* load the decode as entries of this profile */
load_decode_as_entries();
@@ -288,7 +295,9 @@ main(int argc, char *argv[])
/* Build the column format array */
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
- return sharkd_loop();
+ ret = sharkd_loop();
+clean_exit:
+ return ret;
}
static const nstime_t *