summaryrefslogtreecommitdiffstats
path: root/daemon/defer.c
diff options
context:
space:
mode:
authorLukáš Ondráček <lukas.ondracek@nic.cz>2024-10-31 17:39:31 +0100
committerVladimír Čunát <vladimir.cunat@nic.cz>2024-11-04 14:39:48 +0100
commit53db552b054fa2bf804e56d3544ab4a56dbfe918 (patch)
tree3859984c42c806f9bf02f06774a362da427bf64e /daemon/defer.c
parentdaemon/ratelimiting: add log-period and dry-run (diff)
downloadknot-resolver-53db552b054fa2bf804e56d3544ab4a56dbfe918.tar.xz
knot-resolver-53db552b054fa2bf804e56d3544ab4a56dbfe918.zip
daemon/mmapped: use static_assert on undefined padding
Diffstat (limited to 'daemon/defer.c')
-rw-r--r--daemon/defer.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/daemon/defer.c b/daemon/defer.c
index ef24727d..59af3e68 100644
--- a/daemon/defer.c
+++ b/daemon/defer.c
@@ -458,11 +458,12 @@ int defer_init(const char *mmap_file, int cpus)
size_t size = offsetof(struct defer, kru) + KRU.get_size(capacity_log);
size_t header_size = offsetof(struct defer, using_avx2) + sizeof(header.using_avx2);
- kr_assert(header_size ==
- sizeof(header.capacity) +
- sizeof(header.max_decay) +
- sizeof(header.cpus) +
- sizeof(header.using_avx2)); // no undefined padding inside
+ static_assert( // no padding up to .using_avx2
+ offsetof(struct defer, using_avx2) ==
+ sizeof(header.capacity) +
+ sizeof(header.max_decay) +
+ sizeof(header.cpus),
+ "detected padding with undefined data inside mmapped header");
ret = mmapped_init(&defer_mmapped, mmap_file, size, &header, header_size);
if (ret == MMAPPED_WAS_FIRST) {