smadaminov / ovs-dpdk-meson-issues

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

windows meson: OBJECT_OFFSETOF #33

Open williamtu opened 3 years ago

williamtu commented 3 years ago
[10/188] Compiling C object lib/libopenvswitch.a.p/netdev-dummy.c.obj
FAILED: lib/libopenvswitch.a.p/netdev-dummy.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" "-Wno-format" "-Werror" "-dM" "-U_MSC_VER" "-D_TIMESPEC_DEFINED" "-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS" "-D_CRT_SECURE_NO_DEPRECAT
E" -MD -MQ lib/libopenvswitch.a.p/netdev-dummy.c.obj -MF "lib\libopenvswitch.a.p\netdev-dummy.c.obj.d" -o lib/libopenvswitch.a.p/netdev-dummy.c.obj "-c" ../l
ib/netdev-dummy.c
../lib/netdev-dummy.c:245:26: error: variable 'txbuf_node' is uninitialized when used here [-Werror,-Wuninitialized]
        ASSIGN_CONTAINER(txbuf_node, ovs_list_front(&s->txq), list_node);
                         ^~~~~~~~~~
..\include\openvswitch/util.h:139:44: note: expanded from macro 'ASSIGN_CONTAINER'
    ((OBJECT) = OBJECT_CONTAINING(POINTER, OBJECT, MEMBER), (void) 0)
                                           ^~~~~~
..\include\openvswitch/util.h:131:44: note: expanded from macro 'OBJECT_CONTAINING'
     ((char *) (POINTER) - OBJECT_OFFSETOF(OBJECT, MEMBER)))
                                           ^~~~~~
    ((char *) &(OBJECT)->MEMBER - (char *) (OBJECT))
                ^~~~~~
../lib/netdev-dummy.c:241:41: note: initialize the variable 'txbuf_node' to silence this warning
        struct pkt_list_node *txbuf_node;
                                        ^
                                         = NULL
../lib/netdev-dummy.c:1024:26: error: variable 'pkt_node' is uninitialized when used here [-Werror,-Wuninitialized]
        ASSIGN_CONTAINER(pkt_node, ovs_list_pop_front(&rx->recv_queue), list_node);
                         ^~~~~~~~
..\include\openvswitch/util.h:139:44: note: expanded from macro 'ASSIGN_CONTAINER'
    ((OBJECT) = OBJECT_CONTAINING(POINTER, OBJECT, MEMBER), (void) 0)
                                           ^~~~~~
..\include\openvswitch/util.h:131:44: note: expanded from macro 'OBJECT_CONTAINING'
     ((char *) (POINTER) - OBJECT_OFFSETOF(OBJECT, MEMBER)))
                                           ^~~~~~
..\include\openvswitch/util.h:107:17: note: expanded from macro 'OBJECT_OFFSETOF'
    ((char *) &(OBJECT)->MEMBER - (char *) (OBJECT))
                ^~~~~~
../lib/netdev-dummy.c:1022:39: note: initialize the variable 'pkt_node' to silence this warning
        struct pkt_list_node *pkt_node;
                                      ^
                                       = NULL
../lib/netdev-dummy.c:1941:42: error: incompatible pointer types passing 'ULONG *' (aka 'unsigned long *') to parameter of type 'ovs_be32 *' (aka 'unsigned i
nt *') [-Werror,-Wincompatible-pointer-types]
        error = ip_parse_masked(argv[2], &ip.s_addr, &mask.s_addr);
                                         ^~~~~~~~~~
williamtu commented 3 years ago
diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h
index 228b185c3..b3a3b499b 100644
--- a/include/openvswitch/util.h
+++ b/include/openvswitch/util.h
@@ -83,7 +83,7 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);

 /* Given a pointer-typed lvalue OBJECT, expands to a pointer type that may be
  * assigned to OBJECT. */
-#ifdef __GNUC__
+#if (__GNUC__ || __clang__)
 #define OVS_TYPEOF(OBJECT) typeof(OBJECT)
 #elif defined (__cplusplus)
 #define OVS_TYPEOF(OBJECT) decltype(OBJECT)
@@ -100,7 +100,7 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
  * dereference any pointer, so it would be surprising for it to cause any
  * problems in practice.
  */
-#ifdef __GNUC__
+#if (__GNUC__ || __clang__)
 #define OBJECT_OFFSETOF(OBJECT, MEMBER) offsetof(typeof(*(OBJECT)), MEMBER)
 #else
 #define OBJECT_OFFSETOF(OBJECT, MEMBER) \