Message ID | 1442951618-13080-3-git-send-email-aserdean@cloudbasesolutions.com |
---|---|
State | Superseded |
Headers | show |
On Tue, Sep 22, 2015 at 12:53 PM, Alin Serdean <aserdean@cloudbasesolutions.com> wrote: > MSVC does not support zero-size array unless it is the last member of > a defined structure. > > The error is hit only on MSVC 64 bit because the size of > uint64_t is equal with sizeof(struct tun_table *). > > This patch ifdef's out the pad member of the structure tun_metadata > in case we are on the MSVC 64 bit compiler. > > Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> I will let Ben take a look to see if something better can be done here. > --- > lib/tun-metadata.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/tun-metadata.h b/lib/tun-metadata.h > index 624c881..801ed13 100644 > --- a/lib/tun-metadata.h > +++ b/lib/tun-metadata.h > @@ -36,6 +36,7 @@ struct tun_table; > #define TUN_METADATA_NUM_OPTS 64 > #define TUN_METADATA_TOT_OPT_SIZE 256 > > + > /* Tunnel option data, plus metadata to aid in their interpretation. > * > * The option data exists in two forms and is interpreted differently depending > @@ -63,7 +64,9 @@ struct tun_metadata { > uint8_t len; /* Length of data in 'opts'. */ > } present; > struct tun_table *tab; /* Types & lengths for 'opts' and 'opt_map'. */ > +#ifndef _WIN64 > uint8_t pad[sizeof(uint64_t) - sizeof(struct tun_table *)]; /* Make 8 bytes */ > +#endif > union { > uint8_t u8[TUN_METADATA_TOT_OPT_SIZE]; /* Values from tunnel TLVs. */ > struct geneve_opt gnv[GENEVE_TOT_OPT_SIZE / sizeof(struct geneve_opt)]; > -- > 1.9.5.msysgit.0 > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev
On Wed, Sep 23, 2015 at 07:54:04AM -0700, Gurucharan Shetty wrote: > On Tue, Sep 22, 2015 at 12:53 PM, Alin Serdean > <aserdean@cloudbasesolutions.com> wrote: > > MSVC does not support zero-size array unless it is the last member of > > a defined structure. > > > > The error is hit only on MSVC 64 bit because the size of > > uint64_t is equal with sizeof(struct tun_table *). > > > > This patch ifdef's out the pad member of the structure tun_metadata > > in case we are on the MSVC 64 bit compiler. > > > > Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> > > I will let Ben take a look to see if something better can be done here. Oh, a challenge ;-) I sent out a suggestion for review: http://openvswitch.org/pipermail/dev/2015-September/060534.html
diff --git a/lib/tun-metadata.h b/lib/tun-metadata.h index 624c881..801ed13 100644 --- a/lib/tun-metadata.h +++ b/lib/tun-metadata.h @@ -36,6 +36,7 @@ struct tun_table; #define TUN_METADATA_NUM_OPTS 64 #define TUN_METADATA_TOT_OPT_SIZE 256 + /* Tunnel option data, plus metadata to aid in their interpretation. * * The option data exists in two forms and is interpreted differently depending @@ -63,7 +64,9 @@ struct tun_metadata { uint8_t len; /* Length of data in 'opts'. */ } present; struct tun_table *tab; /* Types & lengths for 'opts' and 'opt_map'. */ +#ifndef _WIN64 uint8_t pad[sizeof(uint64_t) - sizeof(struct tun_table *)]; /* Make 8 bytes */ +#endif union { uint8_t u8[TUN_METADATA_TOT_OPT_SIZE]; /* Values from tunnel TLVs. */ struct geneve_opt gnv[GENEVE_TOT_OPT_SIZE / sizeof(struct geneve_opt)];
MSVC does not support zero-size array unless it is the last member of a defined structure. The error is hit only on MSVC 64 bit because the size of uint64_t is equal with sizeof(struct tun_table *). This patch ifdef's out the pad member of the structure tun_metadata in case we are on the MSVC 64 bit compiler. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> --- lib/tun-metadata.h | 3 +++ 1 file changed, 3 insertions(+)