summaryrefslogtreecommitdiff
path: root/lib/type.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-04-14 16:51:18 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-04 15:37:41 +0200
commit1d309c4ce6e95b68c64a8f007f6dd2f1830a5707 (patch)
treefe84dc4c6681c127daee871670aa617e8e2377b5 /lib/type.h
parentc1194ab7edbb17cb7371ac38e6eab5ae3ae72163 (diff)
Enforcing certain data structure explicit paddings.
Implicit paddings have undefined values in C. We want the eattr blocks to be comparable by memcmp and eattrs settable directly by structrure literals. This check ensures that all paddings in eattr and bval are explicit and therefore zeroed in all literals.
Diffstat (limited to 'lib/type.h')
-rw-r--r--lib/type.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/type.h b/lib/type.h
index 6d19a250..e43389f3 100644
--- a/lib/type.h
+++ b/lib/type.h
@@ -13,9 +13,15 @@
#include "lib/attrs.h"
union bval {
-#define BVAL_ITEMS \
- u32 data; /* Integer type inherited from eattrs */ \
- u32 i; /* Integer type inherited from filters */ \
+#define BVAL_ITEMS \
+ struct { \
+ u32 data; /* Integer type inherited from eattrs */ \
+ PADDING(data, 0, 4); /* Must be padded on 64-bits */ \
+ }; \
+ struct { \
+ u32 i; /* Integer type inherited from filters */ \
+ PADDING(i, 0, 4); /* Must be padded on 64-bits */ \
+ }; \
const struct adata *ptr; /* Generic attribute data inherited from eattrs */ \
const struct adata *ad; /* Generic attribute data inherited from filters */ \