diff --git a/CMakeLists.txt b/CMakeLists.txt index d360fd7..5e9d37f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/include/asyncpp/uring/index_set.h b/include/asyncpp/uring/index_set.h index eaff041..128dce1 100644 --- a/include/asyncpp/uring/index_set.h +++ b/include/asyncpp/uring/index_set.h @@ -59,13 +59,13 @@ 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())); @@ -73,7 +73,7 @@ namespace asyncpp::uring { 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) { @@ -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; } @@ -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; diff --git a/include/asyncpp/uring/io_service.h b/include/asyncpp/uring/io_service.h index 7c83484..efdb527 100644 --- a/include/asyncpp/uring/io_service.h +++ b/include/asyncpp/uring/io_service.h @@ -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); @@ -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; @@ -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(m_group.block_size())); ptr = buffer_handle(m_group, bufidx); } return {cqe->res, ptr}; @@ -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(m_group.block_size())); ptr = buffer_handle(m_group, bufidx); } return {cqe->res, ptr};