diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-02-07 15:25:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-07 15:25:05 +0100 |
commit | eb7e35149600f6141e01808115859397c190bff1 (patch) | |
tree | 2ce1d171c06e8d63fab6ca58350ffabec99091f7 /src/libsystemd-network | |
parent | ad28cfebc184393c0c278708fd48e1ca650005a3 (diff) | |
parent | 23cfbcc35eda8150c653b549ae48c3ead0888279 (diff) | |
download | systemd-eb7e35149600f6141e01808115859397c190bff1.tar.gz |
Merge pull request #11578 from keszybz/gcc-9-fixes
Packed struct alignment workarounds for gcc-9
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/radv-internal.h | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/libsystemd-network/radv-internal.h b/src/libsystemd-network/radv-internal.h index cd44352307..66f49ed44e 100644 --- a/src/libsystemd-network/radv-internal.h +++ b/src/libsystemd-network/radv-internal.h @@ -63,19 +63,34 @@ struct sd_radv { struct sd_radv_opt_dns *dnssl; }; +#define radv_prefix_opt__contents { \ + uint8_t type; \ + uint8_t length; \ + uint8_t prefixlen; \ + uint8_t flags; \ + be32_t valid_lifetime; \ + be32_t preferred_lifetime; \ + uint32_t reserved; \ + struct in6_addr in6_addr; \ +} + +struct radv_prefix_opt radv_prefix_opt__contents; + +/* We need the opt substructure to be packed, because we use it in send(). But + * if we use _packed_, this means that the structure cannot be used directly in + * normal code in general, because the fields might not be properly aligned. + * But in this particular case, the structure is defined in a way that gives + * proper alignment, even without the explicit _packed_ attribute. To appease + * the compiler we use the "unpacked" structure, but we also verify that + * structure contains no holes, so offsets are the same when _packed_ is used. + */ +struct radv_prefix_opt__packed radv_prefix_opt__contents _packed_; +assert_cc(sizeof(struct radv_prefix_opt) == sizeof(struct radv_prefix_opt__packed)); + struct sd_radv_prefix { unsigned n_ref; - struct { - uint8_t type; - uint8_t length; - uint8_t prefixlen; - uint8_t flags; - be32_t valid_lifetime; - be32_t preferred_lifetime; - uint32_t reserved; - struct in6_addr in6_addr; - } _packed_ opt; + struct radv_prefix_opt opt; LIST_FIELDS(struct sd_radv_prefix, prefix); |