diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-08-17 18:41:36 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-08-18 01:42:23 +0000 |
commit | 85ebd88083e134304c76af52aa573064e73df19f (patch) | |
tree | 96d6356e6a1aae90498afc0689a196f2b1e4ca8f /wiretap | |
parent | 3ba8a28f50ac695233c711c392aed33d9dd398bf (diff) |
Make it a little clearer what ascend_open() is doing.
Expand comments, and merge two separate if checks.
Change-Id: If339ce632ccc91c425ba6db4a32296c3038253ac
Reviewed-on: https://code.wireshark.org/review/17128
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/ascendtext.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c index 7259fa94bf..a220c020ee 100644 --- a/wiretap/ascendtext.c +++ b/wiretap/ascendtext.c @@ -237,20 +237,25 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info) return WTAP_OPEN_NOT_MINE; } - /* Do a trial parse of the first packet just found to see if we might really have an Ascend file */ - if (run_ascend_parser(wth->fh, &wth->phdr, buf, &parser_state, err, err_info) != 0) { - if (*err != 0) { - /* An I/O error. */ - return WTAP_OPEN_ERROR; - } + /* Do a trial parse of the first packet just found to see if we might + really have an Ascend file. If it fails with an actual error, + fail; those will be I/O errors. */ + if (run_ascend_parser(wth->fh, &wth->phdr, buf, &parser_state, err, + err_info) != 0 && *err != 0) { + /* An I/O error. */ + return WTAP_OPEN_ERROR; } - /* if we got at least some data, and didn't get an I/O error, return - success even if the parser reported an error. This is because the - debug header gives the number of bytes on the wire, not actually - how many bytes are in the trace. We won't know where the data ends - until we run into the next packet. */ + /* Either the parse succeeded, or it failed but didn't get an I/O + error. + + If we got at least some data, return success even if the parser + reported an error. This is because the debug header gives the + number of bytes on the wire, not actually how many bytes are in + the trace. We won't know where the data ends until we run into + the next packet. */ if (parser_state.caplen == 0) { + /* We read no data, so this presumably isn't an Ascend file. */ return WTAP_OPEN_NOT_MINE; } |