[ovs-dev] [arp-rw 04/13] pcap-file: Improve error logging.
Ben Pfaff
blp at nicira.com
Mon Sep 23 17:49:50 UTC 2013
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 at nicira.com>
---
lib/pcap-file.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/pcap-file.c b/lib/pcap-file.c
index d137be8..d181a3e 100644
--- a/lib/pcap-file.c
+++ b/lib/pcap-file.c
@@ -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. */
--
1.7.10.4
More information about the dev
mailing list