summaryrefslogtreecommitdiff
path: root/wiretap/dbs-etherwatch.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-12-27 22:59:39 +0000
committerGuy Harris <guy@alum.mit.edu>2012-12-27 22:59:39 +0000
commitd8b37bafb761f9feaacf5bc6a3aad7e5254159f9 (patch)
tree60a112f6e043dc3420d353f1d86b5ee1a30edd2c /wiretap/dbs-etherwatch.c
parentbb3b34d7bfd1e8510b478fe4ad7a7ba0079ab1b0 (diff)
downloadwireshark-d8b37bafb761f9feaacf5bc6a3aad7e5254159f9.tar.gz
Errors take precedence over EOF; use file_error() after operations that
return an "EOF or error" indication - an EOF without an error will return 0. In iseries_seek_next_packet(), return an error code of WTAP_ERR_BAD_FILE and an appropriate error message if we don't find a packet header within the next ISERIES_MAX_TRACE_LEN lines, don't just return -1 and leave the error information unchanged. Setting an argument variable before returning has no effect, so don't do it (so that we don't leave the mistaken impression that it *is* doing something). Clean up indentation. svn path=/trunk/; revision=46819
Diffstat (limited to 'wiretap/dbs-etherwatch.c')
-rw-r--r--wiretap/dbs-etherwatch.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index 5a46686326..ba0c1a615d 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -124,13 +124,8 @@ static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
level = 0;
}
}
- if (file_eof(wth->fh)) {
- /* We got an EOF. */
- *err = 0;
- } else {
- /* We got an error. */
- *err = file_error(wth->fh, err_info);
- }
+ /* EOF or error. */
+ *err = file_error(wth->fh, err_info);
return -1;
}
@@ -155,33 +150,28 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
buf[DBS_ETHERWATCH_LINE_LENGTH-1] = 0;
for (line = 0; line < DBS_ETHERWATCH_HEADER_LINES_TO_CHECK; line++) {
- if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wth->fh)!=NULL){
-
- reclen = strlen(buf);
- if (reclen < DBS_ETHERWATCH_HDR_MAGIC_SIZE)
- continue;
-
- level = 0;
- for (i = 0; i < reclen; i++) {
- byte = buf[i];
- if (byte == dbs_etherwatch_hdr_magic[level]) {
- level++;
- if (level >=
- DBS_ETHERWATCH_HDR_MAGIC_SIZE) {
- return TRUE;
- }
+ if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wth->fh) == NULL) {
+ /* EOF or error. */
+ *err = file_error(wth->fh, err_info);
+ return FALSE;
+ }
+
+ reclen = strlen(buf);
+ if (reclen < DBS_ETHERWATCH_HDR_MAGIC_SIZE)
+ continue;
+
+ level = 0;
+ for (i = 0; i < reclen; i++) {
+ byte = buf[i];
+ if (byte == dbs_etherwatch_hdr_magic[level]) {
+ level++;
+ if (level >=
+ DBS_ETHERWATCH_HDR_MAGIC_SIZE) {
+ return TRUE;
}
- else
- level = 0;
}
- }
- else {
- /* EOF or error. */
- if (file_eof(wth->fh))
- *err = 0;
else
- *err = file_error(wth->fh, err_info);
- return FALSE;
+ level = 0;
}
}
*err = 0;