diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-17 20:03:47 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-18 04:04:19 +0000 |
commit | 0885d2945103236f7f475963f66048291f0b18f1 (patch) | |
tree | 2c165dd89f97ee9cc33d39f9b7a62840e0ab269b /reordercap.c | |
parent | 6011a047d3cd2aba84e7fdd3bf7e8403a2f3563b (diff) |
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 <guy@alum.mit.edu>
Diffstat (limited to 'reordercap.c')
-rw-r--r-- | reordercap.c | 33 |
1 files changed, 7 insertions, 26 deletions
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; } } |