From 0885d2945103236f7f475963f66048291f0b18f1 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 17 Dec 2014 20:03:47 -0800 Subject: Make sure err_info is always set, and print it iff it's non-null. Change-Id: Ib5c600c491a3d8adcfa91c00fa9445283610545b Reviewed-on: https://code.wireshark.org/review/5830 Reviewed-by: Guy Harris --- reordercap.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'reordercap.c') diff --git a/reordercap.c b/reordercap.c index b36bc58b40..9ac0b6738f 100644 --- a/reordercap.c +++ b/reordercap.c @@ -121,13 +121,9 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, fprintf(stderr, "reordercap: An error occurred while re-reading \"%s\": %s.\n", infile, wtap_strerror(err)); - switch (err) { - - case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_BAD_FILE: + if (err_info != NULL) { fprintf(stderr, "(%s)\n", err_info); g_free(err_info); - break; } exit(1); } @@ -140,18 +136,11 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, /* Dump frame to outfile */ if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err, &err_info)) { - switch (err) { - - case WTAP_ERR_UNWRITABLE_REC_DATA: - fprintf(stderr, "reordercap: Error (%s) writing frame to outfile (%s)\n", - wtap_strerror(err), err_info); + fprintf(stderr, "reordercap: Error (%s) writing frame to outfile\n", + wtap_strerror(err)); + if (err_info != NULL) { + fprintf(stderr, "(%s)\n", err_info); g_free(err_info); - break; - - default: - fprintf(stderr, "reordercap: Error (%s) writing frame to outfile\n", - wtap_strerror(err)); - break; } exit(1); } @@ -293,13 +282,9 @@ main(int argc, char *argv[]) if (wth == NULL) { fprintf(stderr, "reordercap: Can't open %s: %s\n", infile, wtap_strerror(err)); - switch (err) { - - case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_BAD_FILE: + if (err_info != NULL) { fprintf(stderr, "(%s)\n", err_info); g_free(err_info); - break; } exit(1); } @@ -349,13 +334,9 @@ main(int argc, char *argv[]) fprintf(stderr, "reordercap: An error occurred while reading \"%s\": %s.\n", infile, wtap_strerror(err)); - switch (err) { - - case WTAP_ERR_UNSUPPORTED: - case WTAP_ERR_BAD_FILE: + if (err_info != NULL) { fprintf(stderr, "(%s)\n", err_info); g_free(err_info); - break; } } -- cgit v1.2.1