MSVC allows [] but not [0] for arrays in struct definitions,
and does not allow nested [] inside a union.

Reported-by: Alin Serdean <aserd...@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <b...@ovn.org>
---
v1->v2: Avoid [] in nested union also.

 include/openvswitch/nsh.h | 6 +++---
 lib/packets.c             | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/openvswitch/nsh.h b/include/openvswitch/nsh.h
index d9be1e6fa3b4..f4ccadcdc6fb 100644
--- a/include/openvswitch/nsh.h
+++ b/include/openvswitch/nsh.h
@@ -58,7 +58,7 @@ struct nsh_md2_tlv {
     ovs_be16 md_class;
     uint8_t type;
     uint8_t length;
-    uint8_t md_value[];
+    /* Followed by variable-length data. */
 };
 
 struct nsh_hdr {
@@ -68,7 +68,7 @@ struct nsh_hdr {
     ovs_16aligned_be32 path_hdr;
     union {
         struct nsh_md1_ctx md1;
-        struct nsh_md2_tlv md2[0];
+        struct nsh_md2_tlv md2;
     };
 };
 
@@ -125,7 +125,7 @@ nsh_md1_ctx(struct nsh_hdr *nsh)
 static inline struct nsh_md2_tlv *
 nsh_md2_ctx(struct nsh_hdr *nsh)
 {
-    return nsh->md2;
+    return &nsh->md2;
 }
 
 #ifdef  __cplusplus
diff --git a/lib/packets.c b/lib/packets.c
index a304853de4cc..74d87eda89e1 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -438,7 +438,7 @@ encap_nsh(struct dp_packet *packet, const struct 
ovs_action_encap_nsh *encap)
         case NSH_M_TYPE2: {
             /* The MD2 metadata in encap is already padded to 4 bytes. */
             size_t len = ROUND_UP(encap->mdlen, 4);
-            memcpy(nsh->md2, encap->metadata, len);
+            memcpy(&nsh->md2, encap->metadata, len);
             break;
         }
         default:
-- 
2.10.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to