Skip to content

Commit

Permalink
folly io_uring: properly zero initialise folly::IoUringOp
Browse files Browse the repository at this point in the history
Summary: Properly zero initialize `sqe_`, `cqe_` and `iov_` in `folly::IoUringOp`.

Reviewed By: capickett

Differential Revision: D62283277

fbshipit-source-id: 58feabccaa99df5940321d3a9594a18abca2126c
  • Loading branch information
spikeh authored and facebook-github-bot committed Sep 7, 2024
1 parent f72d61b commit 2fb0ca3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion folly/io/async/IoUring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ void toStream(std::ostream& os, const struct io_uring_sqe& sqe) {
namespace folly {

IoUringOp::IoUringOp(NotificationCallback cb, Options options)
: AsyncBaseOp(std::move(cb)), options_(options) {}
: AsyncBaseOp(std::move(cb)), options_(options) {
::memset(iov_, 0, sizeof(iov_));
}

void IoUringOp::reset(NotificationCallback cb) {
CHECK_NE(state_, State::PENDING);
Expand Down
4 changes: 2 additions & 2 deletions folly/io/async/IoUring.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ class IoUringOp : public AsyncBaseOp {
union {
struct io_uring_sqe sqe;
uint8_t data[128];
} sqe_;
} sqe_ = {};

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

struct iovec iov_[1];
};
Expand Down

0 comments on commit 2fb0ca3

Please sign in to comment.