From adb9282b0e0b56fc4980c1908d649d41ce6df223 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 17 May 2013 09:37:02 +0000 Subject: If iseries_seek_next_packet() hits the EOF, *err will be set to 0; just have it return -1 for errors or EOF, and have iseries_read() check for a negative return value and return FALSE. That simplifies it a bit, and handles the "no more records in the file" case (iseries_seek_next_packet() will hit EOF and return -1 with *err set to 0, which is what the callers of a read routine expect at EOF). Get rid of duplicate (and incorrect before the change) comment. svn path=/trunk/; revision=49375 --- wiretap/iseries.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'wiretap') diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 45911b2fac..51dfd1062c 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -383,7 +383,7 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset) * Locate the next packet */ offset = iseries_seek_next_packet (wth, err, err_info); - if (offset < 1) + if (offset < 0) return FALSE; /* @@ -401,8 +401,9 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset) /* * Seeks to the beginning of the next packet, and returns the - * byte offset. Returns -1 on failure, and sets *err to the error - * and *err_info to null or an additional error string. + * byte offset. Returns -1 on failure or EOF; on EOF, sets + * *err to 0, and, on failure, sets *err to the error and *err_info + * to null or an additional error string. */ static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info) @@ -413,22 +414,13 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info) gint64 cur_off; long buflen; - /* - * Seeks to the beginning of the next packet, and returns the - * byte offset. Returns -1 on failure, and sets *err to the error - * and *err_info to null or an additional error string. - */ for (line = 0; line < ISERIES_MAX_TRACE_LEN; line++) { if (file_gets (buf, ISERIES_LINE_LENGTH, wth->fh) == NULL) { /* EOF or error. */ *err = file_error (wth->fh, err_info); - if (*err != 0) - { - return -1; - } - return 0; + return -1; } /* Convert UNICODE to ASCII if required and determine */ /* the number of bytes to rewind to beginning of record. */ -- cgit v1.2.1