diff mbox series

[ovs-dev] pcap-file: Correctly format enum type.

Message ID 20181116172511.7908-1-blp@ovn.org
State Accepted
Headers show
Series [ovs-dev] pcap-file: Correctly format enum type. | expand

Commit Message

Ben Pfaff Nov. 16, 2018, 5:25 p.m. UTC
The underlying type for an enum is somewhat unpredictable in that the
compiler and the ABI influence it.  The format specifier I used here was
apparently correct for i386 on Linux but wrong for x86-64.  It's better to
just use a cast.

Reported-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 lib/pcap-file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Horman Nov. 16, 2018, 6:21 p.m. UTC | #1
On Fri, Nov 16, 2018 at 09:25:11AM -0800, Ben Pfaff wrote:
> The underlying type for an enum is somewhat unpredictable in that the
> compiler and the ABI influence it.  The format specifier I used here was
> apparently correct for i386 on Linux but wrong for x86-64.  It's better to
> just use a cast.
> 
> Reported-by: Simon Horman <simon.horman@netronome.com>
> Signed-off-by: Ben Pfaff <blp@ovn.org>

Thanks Ben,

this looks good to me.

Reviewed-by: Simon Horman <simon.horman@netronome.com>
Ben Pfaff Nov. 16, 2018, 6:55 p.m. UTC | #2
On Fri, Nov 16, 2018 at 10:21:22AM -0800, Simon Horman wrote:
> On Fri, Nov 16, 2018 at 09:25:11AM -0800, Ben Pfaff wrote:
> > The underlying type for an enum is somewhat unpredictable in that the
> > compiler and the ABI influence it.  The format specifier I used here was
> > apparently correct for i386 on Linux but wrong for x86-64.  It's better to
> > just use a cast.
> > 
> > Reported-by: Simon Horman <simon.horman@netronome.com>
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> 
> Thanks Ben,
> 
> this looks good to me.
> 
> Reviewed-by: Simon Horman <simon.horman@netronome.com>

Thanks, I applied this to master.
diff mbox series

Patch

diff --git a/lib/pcap-file.c b/lib/pcap-file.c
index 863a9a6c7bf2..e4e92b8c20ef 100644
--- a/lib/pcap-file.c
+++ b/lib/pcap-file.c
@@ -153,8 +153,8 @@  ovs_pcap_read_header(struct pcap_file *p_file)
     p_file->network = byte_swap ? uint32_byteswap(ph.network) : ph.network;
     if (p_file->network != PCAP_ETHERNET &&
         p_file->network != PCAP_LINUX_SLL) {
-        VLOG_WARN("unknown network type %"PRIu16" reading pcap file",
-                  p_file->network);
+        VLOG_WARN("unknown network type %u reading pcap file",
+                  (unsigned int) p_file->network);
         return EPROTO;
     }
     return 0;