diff options
author | Andrew Evans <aevans@nicira.com> | 2011-01-30 11:29:14 -0800 |
---|---|---|
committer | Andrew Evans <aevans@nicira.com> | 2011-01-30 17:54:59 -0800 |
commit | c18ea70d06e980dc768166881c5aeac0b3491561 (patch) | |
tree | 32627f13f7534c419bc0dc8118b68a2d0971b990 /lib/pcap.c | |
parent | 8ce41058990860158a4b9d31b52de46558eee6a5 (diff) |
util: New ovs_retval_to_string() function.
Many OVS functions return 0, EOF, or errno. There are several places in the
codebase where a return value is converted to a string. All must decide whether
the return value is set, and if it is, whether it is an errno value, EOF, or
otherwise invalid. This commit consolidates that code.
Reviewed by Ben Pfaff.
Diffstat (limited to 'lib/pcap.c')
-rw-r--r-- | lib/pcap.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -76,8 +76,7 @@ pcap_read_header(FILE *file) struct pcap_hdr ph; if (fread(&ph, sizeof ph, 1, file) != 1) { int error = ferror(file) ? errno : EOF; - VLOG_WARN("failed to read pcap header: %s", - error > 0 ? strerror(error) : "end of file"); + VLOG_WARN("failed to read pcap header: %s", ovs_retval_to_string(error)); return error; } if (ph.magic_number != 0xa1b2c3d4 && ph.magic_number != 0xd4c3b2a1) { @@ -118,7 +117,7 @@ pcap_read(FILE *file, struct ofpbuf **bufp) if (fread(&prh, sizeof prh, 1, file) != 1) { int error = ferror(file) ? errno : EOF; VLOG_WARN("failed to read pcap record header: %s", - error > 0 ? strerror(error) : "end of file"); + ovs_retval_to_string(error)); return error; } @@ -144,7 +143,7 @@ pcap_read(FILE *file, struct ofpbuf **bufp) if (fread(data, len, 1, file) != 1) { int error = ferror(file) ? errno : EOF; VLOG_WARN("failed to read pcap packet: %s", - error > 0 ? strerror(error) : "end of file"); + ovs_retval_to_string(error)); ofpbuf_delete(buf); return error; } |