Skip to content

fix gcc warning #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ if(OP_LAST_COMPILE_RESULT)
target_compile_definitions(asyncpp_uring
INTERFACE ASYNCPP_URING_OP_LAST=${OP_LAST})
endif()
# mismatched-new-delete: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109224
target_compile_options(asyncpp_uring INTERFACE -Wall -Wextra -Wpedantic -Werror
-Wno-error=mismatched-new-delete)

if(ASYNCPP_BUILD_TEST)
enable_testing()
Expand Down
9 changes: 4 additions & 5 deletions include/asyncpp/uring/index_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ namespace asyncpp::uring {
static constexpr size_t bits_per_element = sizeof(element_type) * 8;

constexpr bit_storage(const Allocator& alloc = Allocator{}) noexcept : m_allocator{alloc} {
memset(&m_data, 0, sizeof(m_data));
m_data = {};
m_data.inplace.size = 0x80;
}
~bit_storage() noexcept { clear(); }

bit_storage(const bit_storage& other) : m_allocator{other.m_allocator} {
memset(&m_data, 0, sizeof(m_data));
m_data = {};
m_data.inplace.size = 0x80;
resize_bits(other.bit_size());
memcpy(data(), other.data(), std::min(byte_size(), other.byte_size()));
}

bit_storage(bit_storage&& other) : m_allocator{std::move(other.m_allocator)} {
memcpy(&m_data, &other.m_data, sizeof(other.m_data));
memset(&other.m_data, 0, sizeof(other.m_data));
other.m_data = {};
}

bit_storage& operator=(const bit_storage& other) {
Expand All @@ -88,7 +88,7 @@ namespace asyncpp::uring {
this->clear();
m_allocator = std::move(other.m_allocator);
memcpy(&m_data, &other.m_data, sizeof(other.m_data));
memset(&other.m_data, 0, sizeof(other.m_data));
other.m_data = {};
return *this;
}

Expand Down Expand Up @@ -186,7 +186,6 @@ namespace asyncpp::uring {
return cnt;
}
T allocate_index() {
const element_type last_element_mask = (element_type{1} << (m_storage.bit_size() % bits_per_element)) - 1;
auto* data = m_storage.data();
const auto elements = bit_storage::num_elements(m_storage.bit_size());
bool found = false;
Expand Down
12 changes: 6 additions & 6 deletions include/asyncpp/uring/io_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace asyncpp::uring {
constexpr unsigned int sqe_size() const noexcept { return m_sqe_size; }
};

uring(const params& p = params{}) : m_ring{}, m_caps{capability_set::no_parse_tag}, m_params{p} {
uring(const params& p = params{}) : m_params{p}, m_ring{}, m_caps{capability_set::no_parse_tag} {

auto res = io_uring_queue_init_params(m_params.sqe_size(), &m_ring, &m_params.raw());
//auto res = io_uring_queue_init(m_params.sqe_size(), &m_ring, 0);
Expand Down Expand Up @@ -395,12 +395,12 @@ namespace asyncpp::uring {

io_service(const params& params = io_service::params{}) //
: uring{params}, //
m_dispatched_wake{eventfd(0, 0)}, //
#ifdef IORING_FEAT_CQE_SKIP
skip_success_flags{has_feature(IORING_FEAT_CQE_SKIP) ? ioseq_flag::cqe_skip_success : ioseq_flag::none}
skip_success_flags{has_feature(IORING_FEAT_CQE_SKIP) ? ioseq_flag::cqe_skip_success : ioseq_flag::none},
#else
skip_success_flags{ioseq_flag::none}
skip_success_flags{ioseq_flag::none},
#endif
m_dispatched_wake{eventfd(0, 0)} //
{
set_null_cqe_handler([](const io_uring_cqe* cqe) {
if (cqe->res < 0) std::cerr << "Error on null sqe: " << cqe->res << " " << strerror(-cqe->res) << std::endl;
Expand Down Expand Up @@ -881,7 +881,7 @@ namespace asyncpp::uring {
buffer_handle ptr;
if (cqe->flags & IORING_CQE_F_BUFFER) {
auto bufidx = cqe->flags >> IORING_CQE_BUFFER_SHIFT;
assert(cqe->res <= m_group.block_size());
assert(cqe->res <= static_cast<long>(m_group.block_size()));
ptr = buffer_handle(m_group, bufidx);
}
return {cqe->res, ptr};
Expand All @@ -892,7 +892,7 @@ namespace asyncpp::uring {
buffer_handle ptr;
if (cqe->flags & IORING_CQE_F_BUFFER) {
auto bufidx = cqe->flags >> IORING_CQE_BUFFER_SHIFT;
assert(cqe->res <= m_group.block_size());
assert(cqe->res <= static_cast<long>(m_group.block_size()));
ptr = buffer_handle(m_group, bufidx);
}
return {cqe->res, ptr};
Expand Down