From 76d85e5c39c909b68bdc60ea02e48cc66b7a77e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20L=C3=BCke?= Date: Thu, 26 Dec 2024 15:28:17 +0100 Subject: [PATCH] mnode_nng_proto: fix warning --- src/mnode_nng_proto.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mnode_nng_proto.cc b/src/mnode_nng_proto.cc index a8f7823..f429dde 100644 --- a/src/mnode_nng_proto.cc +++ b/src/mnode_nng_proto.cc @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include namespace mesytec::mnode::nng { @@ -9,10 +9,11 @@ size_t serialize_proto_to_nng(const google::protobuf::MessageLite &message, nng_ { auto messageSize = message.ByteSizeLong(); - if (auto res = nng_msg_realloc(msg, nng_msg_len(msg) + sizeof(u32) + messageSize)) + if (nng_msg_realloc(msg, nng_msg_len(msg) + sizeof(u32) + messageSize)) return 0; *reinterpret_cast(nng_msg_body(msg)) = messageSize; + if (!message.SerializeToArray(reinterpret_cast(nng_msg_body(msg)) + sizeof(u32), messageSize)) { @@ -35,7 +36,7 @@ size_t deserialize_proto_from_nng(google::protobuf::MessageLite &message, nng_ms return 0; if (!message.ParseFromArray(reinterpret_cast(nng_msg_body(msg)) + sizeof(u32), - messageSize)) + messageSize)) { return 0; }