Skip to content

Commit b81442c

Browse files
committed
Fully initialize ev.data.
On Linux systems, ev.data is an 8-byte field, but this code currently initializes only 4 bytes of the field, leaving the trailing 4 bytes unininitialized. This causes memory safety tools like Valgrind to complain. This patch no longer explicitly initializes .data, ensuring that C structure initialization will force the .data field to be zero initialized. Manual checks of the compiled binary show that the compiler correctly initializes the 4 bytes for u32 only once, so this change incurs minimal overhead.
1 parent e52c174 commit b81442c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/event/event_epoll.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,14 @@ _dispatch_timeout_program(uint32_t tidx, uint64_t target,
391391
dispatch_epoll_timeout_t timer = &_dispatch_epoll_timeout[clock];
392392
struct epoll_event ev = {
393393
.events = EPOLLONESHOT | EPOLLIN,
394-
.data = { .u32 = timer->det_ident },
394+
395395
};
396396
int op;
397397

398398
if (target >= INT64_MAX && !timer->det_registered) {
399399
return;
400400
}
401+
ev.data.u32 = timer->det_ident;
401402

402403
if (unlikely(timer->det_fd < 0)) {
403404
clockid_t clockid;

0 commit comments

Comments
 (0)