]> git.proxmox.com Git - mirror_ovs.git/commitdiff
pcap-file: Improve error logging.
authorBen Pfaff <blp@nicira.com>
Mon, 23 Sep 2013 17:14:35 +0000 (10:14 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 10 Oct 2013 00:02:57 +0000 (17:02 -0700)
There is no reason to log end of file as an error, but that's what this
code was doing.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/pcap-file.c

index d137be81f3d6f5c1dc6f90b526a3d10a03040423..d181a3ed4ecb7751de7ba3e6227d67cb3884475a 100644 (file)
@@ -114,10 +114,14 @@ pcap_read(FILE *file, struct ofpbuf **bufp)
 
     /* Read header. */
     if (fread(&prh, sizeof prh, 1, file) != 1) {
-        int error = ferror(file) ? errno : EOF;
-        VLOG_WARN("failed to read pcap record header: %s",
-                  ovs_retval_to_string(error));
-        return error;
+        if (ferror(file)) {
+            int error = errno;
+            VLOG_WARN("failed to read pcap record header: %s",
+                      ovs_retval_to_string(error));
+            return error;
+        } else {
+            return EOF;
+        }
     }
 
     /* Calculate length. */