Skip to content

Commit bae1d2f

Browse files
committed
fix: use explicit conversions for msg pointers
1 parent d5f8199 commit bae1d2f

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

src/incoming_msg.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Napi::Value IncomingMsg::IntoBuffer(const Napi::Env& env) {
2727
return env.Undefined();
2828
}
2929
}
30-
auto* data = reinterpret_cast<uint8_t*>(zmq_msg_data(*ref));
31-
auto length = zmq_msg_size(*ref);
30+
auto* data = reinterpret_cast<uint8_t*>(zmq_msg_data(ref->get()));
31+
auto length = zmq_msg_size(ref->get());
3232

3333
if (noElectronMemoryCage) {
3434
static auto constexpr zero_copy_threshold = 1U << 7U;
@@ -43,7 +43,7 @@ Napi::Value IncomingMsg::IntoBuffer(const Napi::Env& env) {
4343
env, static_cast<int64_t>(length));
4444

4545
auto release = [](const Napi::Env& env, uint8_t*, Reference* ref) {
46-
const auto length = static_cast<int64_t>(zmq_msg_size(*ref));
46+
const auto length = static_cast<int64_t>(zmq_msg_size(ref->get()));
4747
Napi::MemoryManagement::AdjustExternalMemory(env, -length);
4848
delete ref;
4949
};

src/incoming_msg.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ class IncomingMsg {
1515

1616
Napi::Value IntoBuffer(const Napi::Env& env);
1717

18-
// NOLINTNEXTLINE(*-explicit-*)
19-
inline operator zmq_msg_t*() {
20-
return *ref;
18+
zmq_msg_t* get() {
19+
return ref->get();
2120
}
2221

2322
private:
@@ -28,8 +27,7 @@ class IncomingMsg {
2827
Reference();
2928
~Reference();
3029

31-
// NOLINTNEXTLINE(*-explicit-*)
32-
inline operator zmq_msg_t*() {
30+
zmq_msg_t* get() {
3331
return &msg;
3432
}
3533
};

src/outgoing_msg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class OutgoingMsg {
2424
explicit OutgoingMsg(Napi::Value value, Module& module);
2525
~OutgoingMsg();
2626

27-
// NOLINTNEXTLINE(*-explicit-*)
28-
inline operator zmq_msg_t*() {
27+
zmq_msg_t* get() {
2928
return &msg;
3029
}
3130

src/socket.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void Socket::Send(const Napi::Promise::Deferred& res, OutgoingMsg::Parts& parts)
295295
iter++;
296296

297297
auto const flags = iter == end ? ZMQ_DONTWAIT : ZMQ_DONTWAIT | ZMQ_SNDMORE;
298-
while (zmq_msg_send(part, socket, flags) < 0) {
298+
while (zmq_msg_send(part.get(), socket, flags) < 0) {
299299
if (zmq_errno() != EINTR) {
300300
res.Reject(ErrnoException(Env(), zmq_errno()).Value());
301301
return;
@@ -314,7 +314,7 @@ void Socket::Receive(const Napi::Promise::Deferred& res) {
314314
uint32_t i = 0;
315315
while (true) {
316316
IncomingMsg part;
317-
while (zmq_msg_recv(part, socket, ZMQ_DONTWAIT) < 0) {
317+
while (zmq_msg_recv(part.get(), socket, ZMQ_DONTWAIT) < 0) {
318318
if (zmq_errno() != EINTR) {
319319
res.Reject(ErrnoException(Env(), zmq_errno()).Value());
320320
return;
@@ -343,7 +343,7 @@ void Socket::Receive(const Napi::Promise::Deferred& res) {
343343
}
344344
#endif
345345

346-
if (zmq_msg_more(part) == 0) {
346+
if (zmq_msg_more(part.get()) == 0) {
347347
break;
348348
}
349349
}

0 commit comments

Comments
 (0)