dpif-netdev: Avoid variable length array on MSVC.
authorAlin Serdean <aserdean@cloudbasesolutions.com>
Mon, 1 Sep 2014 20:11:54 +0000 (20:11 +0000)
committerBen Pfaff <blp@nicira.com>
Tue, 2 Sep 2014 15:10:24 +0000 (08:10 -0700)
MSVC does not like variable length array either.

This patch treats the following error:

lib/dpif-netdev.c(2272) : error C2057: expected constant expression
lib/dpif-netdev.c(2272) : error C2466: cannot allocate an array of constant size 0
lib/dpif-netdev.c(2272) : error C2133: 'batches' : unknown size
lib/dpif-netdev.c(2273) : error C2057: expected constant expression
lib/dpif-netdev.c(2273) : error C2466: cannot allocate an array of constant size 0
lib/dpif-netdev.c(2273) : error C2133: 'mfs' : unknown size
lib/dpif-netdev.c(2274) : error C2057: expected constant expression
lib/dpif-netdev.c(2274) : error C2466: cannot allocate an array of constant size 0
lib/dpif-netdev.c(2274) : error C2133: 'rules' : unknown size
lib/dpif-netdev.c(2363) : warning C4034: sizeof returns 0
lib/dpif-netdev.c(2381) : error C2057: expected constant expression
lib/dpif-netdev.c(2381) : error C2466: cannot allocate an array of constant size 0
lib/dpif-netdev.c(2381) : error C2133: 'keys' : unknown size
make[2]: *** [lib/dpif-netdev.lo] Error 1

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/dpif-netdev.c

index 0ccf47d..2476435 100644 (file)
@@ -2263,10 +2263,10 @@ fast_path_processing(struct dp_netdev *dp, struct emc_cache *flow_cache,
                      struct dpif_packet **packets, size_t cnt,
                      struct pkt_metadata *md, struct netdev_flow_key *keys)
 {
-#ifndef __CHECKER__
+#if !defined(__CHECKER__) && !defined(_WIN32)
     const size_t PKT_ARRAY_SIZE = cnt;
 #else
-    /* Sparse doesn't like variable length array */
+    /* Sparse or MSVC doesn't like variable length array. */
     enum { PKT_ARRAY_SIZE = NETDEV_MAX_RX_BATCH };
 #endif
     struct packet_batch batches[PKT_ARRAY_SIZE];
@@ -2372,10 +2372,10 @@ static void
 dp_netdev_input(struct dp_netdev *dp, struct emc_cache *flow_cache,
                 struct dpif_packet **packets, int cnt, struct pkt_metadata *md)
 {
-#ifndef __CHECKER__
+#if !defined(__CHECKER__) && !defined(_WIN32)
     const size_t PKT_ARRAY_SIZE = cnt;
 #else
-    /* Sparse doesn't like variable length array */
+    /* Sparse or MSVC doesn't like variable length array. */
     enum { PKT_ARRAY_SIZE = NETDEV_MAX_RX_BATCH };
 #endif
     struct netdev_flow_key keys[PKT_ARRAY_SIZE];