Skip to content

Commit d9b7bb2

Browse files
authored
Fix gcc warning (#5)
1 parent 38a240d commit d9b7bb2

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ if(OP_LAST_COMPILE_RESULT)
3939
target_compile_definitions(asyncpp_uring
4040
INTERFACE ASYNCPP_URING_OP_LAST=${OP_LAST})
4141
endif()
42+
# mismatched-new-delete: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109224
43+
target_compile_options(asyncpp_uring INTERFACE -Wall -Wextra -Wpedantic -Werror
44+
-Wno-error=mismatched-new-delete)
4245

4346
if(ASYNCPP_BUILD_TEST)
4447
enable_testing()

include/asyncpp/uring/index_set.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ namespace asyncpp::uring {
5959
static constexpr size_t bits_per_element = sizeof(element_type) * 8;
6060

6161
constexpr bit_storage(const Allocator& alloc = Allocator{}) noexcept : m_allocator{alloc} {
62-
memset(&m_data, 0, sizeof(m_data));
62+
m_data = {};
6363
m_data.inplace.size = 0x80;
6464
}
6565
~bit_storage() noexcept { clear(); }
6666

6767
bit_storage(const bit_storage& other) : m_allocator{other.m_allocator} {
68-
memset(&m_data, 0, sizeof(m_data));
68+
m_data = {};
6969
m_data.inplace.size = 0x80;
7070
resize_bits(other.bit_size());
7171
memcpy(data(), other.data(), std::min(byte_size(), other.byte_size()));
7272
}
7373

7474
bit_storage(bit_storage&& other) : m_allocator{std::move(other.m_allocator)} {
7575
memcpy(&m_data, &other.m_data, sizeof(other.m_data));
76-
memset(&other.m_data, 0, sizeof(other.m_data));
76+
other.m_data = {};
7777
}
7878

7979
bit_storage& operator=(const bit_storage& other) {
@@ -88,7 +88,7 @@ namespace asyncpp::uring {
8888
this->clear();
8989
m_allocator = std::move(other.m_allocator);
9090
memcpy(&m_data, &other.m_data, sizeof(other.m_data));
91-
memset(&other.m_data, 0, sizeof(other.m_data));
91+
other.m_data = {};
9292
return *this;
9393
}
9494

@@ -186,7 +186,6 @@ namespace asyncpp::uring {
186186
return cnt;
187187
}
188188
T allocate_index() {
189-
const element_type last_element_mask = (element_type{1} << (m_storage.bit_size() % bits_per_element)) - 1;
190189
auto* data = m_storage.data();
191190
const auto elements = bit_storage::num_elements(m_storage.bit_size());
192191
bool found = false;

include/asyncpp/uring/io_service.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ namespace asyncpp::uring {
259259
constexpr unsigned int sqe_size() const noexcept { return m_sqe_size; }
260260
};
261261

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

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

396396
io_service(const params& params = io_service::params{}) //
397397
: uring{params}, //
398-
m_dispatched_wake{eventfd(0, 0)}, //
399398
#ifdef IORING_FEAT_CQE_SKIP
400-
skip_success_flags{has_feature(IORING_FEAT_CQE_SKIP) ? ioseq_flag::cqe_skip_success : ioseq_flag::none}
399+
skip_success_flags{has_feature(IORING_FEAT_CQE_SKIP) ? ioseq_flag::cqe_skip_success : ioseq_flag::none},
401400
#else
402-
skip_success_flags{ioseq_flag::none}
401+
skip_success_flags{ioseq_flag::none},
403402
#endif
403+
m_dispatched_wake{eventfd(0, 0)} //
404404
{
405405
set_null_cqe_handler([](const io_uring_cqe* cqe) {
406406
if (cqe->res < 0) std::cerr << "Error on null sqe: " << cqe->res << " " << strerror(-cqe->res) << std::endl;
@@ -881,7 +881,7 @@ namespace asyncpp::uring {
881881
buffer_handle ptr;
882882
if (cqe->flags & IORING_CQE_F_BUFFER) {
883883
auto bufidx = cqe->flags >> IORING_CQE_BUFFER_SHIFT;
884-
assert(cqe->res <= m_group.block_size());
884+
assert(cqe->res <= static_cast<long>(m_group.block_size()));
885885
ptr = buffer_handle(m_group, bufidx);
886886
}
887887
return {cqe->res, ptr};
@@ -892,7 +892,7 @@ namespace asyncpp::uring {
892892
buffer_handle ptr;
893893
if (cqe->flags & IORING_CQE_F_BUFFER) {
894894
auto bufidx = cqe->flags >> IORING_CQE_BUFFER_SHIFT;
895-
assert(cqe->res <= m_group.block_size());
895+
assert(cqe->res <= static_cast<long>(m_group.block_size()));
896896
ptr = buffer_handle(m_group, bufidx);
897897
}
898898
return {cqe->res, ptr};

0 commit comments

Comments
 (0)