smadaminov / ovs-dpdk-meson-issues

VMware Summer 2021
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

windows meson: -Wformat IP_ARGS CT_VLOG #31

Open williamtu opened 3 years ago

williamtu commented 3 years ago
FAILED: lib/libopenvswitch.a.p/conntrack.c.obj
"clang" "-Ilib\libopenvswitch.a.p" "-Ilib" "-I..\lib" "-I." "-I.." "-Iinclude\openflow" "-I..\include\openflow" "-Iinclude\openvswitch" "-I..\include\openvsw
itch" "-I..\include\windows" "-Iinclude" "-I..\include" "-I..\datapath-windows\include" "-IC:\PTHREADS-BUILT\include" "-Xclang" "-fcolor-diagnostics" "-pipe"
 "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-g" "-Wthread-safety" "-Wno-microsoft-enum-forward-reference" "-Wno-unused-function" "-Wno-sometimes-unini
tialized" "-Werror" "-dM" "-U_MSC_VER" "-D_TIMESPEC_DEFINED" "-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS" "-D_CRT_SECURE_NO_DEPRECATE" -MD -MQ lib
/libopenvswitch.a.p/conntrack.c.obj -MF "lib\libopenvswitch.a.p\conntrack.c.obj.d" -o lib/libopenvswitch.a.p/conntrack.c.obj "-c" ../lib/conntrack.c
../lib/conntrack.c:255:21: error: format specifies type 'unsigned int' but the argument has type 'u_long' (aka 'unsigned long') [-Werror,-Wformat]
                    IP_ARGS(c->key.src.addr.ipv4),
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..\lib/packets.h:628:5: note: expanded from macro 'IP_ARGS'
    ntohl(ip) >> 24,                            \
    ^
../lib/conntrack.c:241:56: note: expanded from macro 'CT_VLOG'
            vlog_rate_limit(&this_module, LEVEL, &rl_, __VA_ARGS__);        \
                                                       ^~~~~~~~~~~
../lib/conntrack.c:255:21: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat]
                    IP_ARGS(c->key.src.addr.ipv4),
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
williamtu commented 3 years ago

https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-ntohl

ntohl returns u_long

williamtu commented 3 years ago

maybe

diff --git a/lib/packets.h b/lib/packets.h
index 515bb59b1..d227031f7 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -625,10 +625,10 @@ mpls_lse_to_bos(ovs_be32 mpls_lse)

 #define IP_FMT "%"PRIu32".%"PRIu32".%"PRIu32".%"PRIu32
 #define IP_ARGS(ip)                             \
-    ntohl(ip) >> 24,                            \
-    (ntohl(ip) >> 16) & 0xff,                   \
-    (ntohl(ip) >> 8) & 0xff,                    \
-    ntohl(ip) & 0xff
+    (u_int)(ntohl(ip) >> 24),                            \
+    (u_int)((ntohl(ip) >> 16) & 0xff),                   \
+    (u_int)((ntohl(ip) >> 8) & 0xff),                    \
+    (u_int)(ntohl(ip) & 0xff)

 /* Example:
  *