aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/cosine.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/cosine.c
parentbb3b34d7bfd1e8510b478fe4ad7a7ba0079ab1b0 (diff)
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/cosine.c')
-rw-r--r--wiretap/cosine.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index f0d67306c7..183ca241a7 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -200,8 +200,8 @@ static gboolean empty_line(const gchar *line)
/* Seeks to the beginning of the next packet, and returns the
byte offset. Copy the header line to hdr. Returns -1 on failure,
- and sets "*err" to the error, sets "*err_info" to null or an
- additional error string, and sets hdr to NULL. */
+ and sets "*err" to the error and sets "*err_info" to null or an
+ additional error string. */
static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
char *hdr)
{
@@ -213,27 +213,18 @@ static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
if (cur_off == -1) {
/* Error */
*err = file_error(wth->fh, err_info);
- hdr = NULL;
return -1;
}
- if (file_gets(buf, sizeof(buf), wth->fh) != NULL) {
- if (strstr(buf, COSINE_REC_MAGIC_STR1) ||
- strstr(buf, COSINE_REC_MAGIC_STR2)) {
- g_strlcpy(hdr, buf, COSINE_LINE_LENGTH);
- return cur_off;
- }
- } else {
- if (file_eof(wth->fh)) {
- /* We got an EOF. */
- *err = 0;
- } else {
- /* We got an error. */
- *err = file_error(wth->fh, err_info);
- }
- break;
+ if (file_gets(buf, sizeof(buf), wth->fh) == NULL) {
+ *err = file_error(wth->fh, err_info);
+ return -1;
+ }
+ if (strstr(buf, COSINE_REC_MAGIC_STR1) ||
+ strstr(buf, COSINE_REC_MAGIC_STR2)) {
+ g_strlcpy(hdr, buf, COSINE_LINE_LENGTH);
+ return cur_off;
}
}
- hdr = NULL;
return -1;
}