Skip to content

Commit 2fb0ca3

Browse files
spikehfacebook-github-bot
authored andcommitted
folly io_uring: properly zero initialise folly::IoUringOp
Summary: Properly zero initialize `sqe_`, `cqe_` and `iov_` in `folly::IoUringOp`. Reviewed By: capickett Differential Revision: D62283277 fbshipit-source-id: 58feabccaa99df5940321d3a9594a18abca2126c
1 parent f72d61b commit 2fb0ca3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

folly/io/async/IoUring.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ void toStream(std::ostream& os, const struct io_uring_sqe& sqe) {
114114
namespace folly {
115115

116116
IoUringOp::IoUringOp(NotificationCallback cb, Options options)
117-
: AsyncBaseOp(std::move(cb)), options_(options) {}
117+
: AsyncBaseOp(std::move(cb)), options_(options) {
118+
::memset(iov_, 0, sizeof(iov_));
119+
}
118120

119121
void IoUringOp::reset(NotificationCallback cb) {
120122
CHECK_NE(state_, State::PENDING);

folly/io/async/IoUring.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ class IoUringOp : public AsyncBaseOp {
112112
union {
113113
struct io_uring_sqe sqe;
114114
uint8_t data[128];
115-
} sqe_;
115+
} sqe_ = {};
116116

117117
// we have to use a union here because of -Wgnu-variable-sized-type-not-at-end
118118
//__u64 big_cqe[];
119119
union {
120120
__u64 user_data; // first member from from io_uring_cqe
121121
uint8_t data[32];
122-
} cqe_;
122+
} cqe_ = {};
123123

124124
struct iovec iov_[1];
125125
};

0 commit comments

Comments
 (0)