From dcb737feed8b9f16d033326940e0072a910b8b30 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Thu, 1 Jun 2023 22:27:57 +0800 Subject: [PATCH] Fix compiler warning and signedness issue (#401) * Fix compiler warning and signedness issue This commit fixes a compiler warning I was getting with regard to signed and unsigned types. On line 794 of `Discovery.hh` we use the recvfrom but we use an unsigned int to check if the error is correct or not. By default recvfrom returns an `ssize_t` not a `uint16_t`. It seems a fix for this has landed in garden but has not been backported to citadel or fortress. Signed-off-by: Arjo Chakravarty * Switch to `int64_t` to make m$s$ w1nd0ws happy Rant: At this point I'm not sure that a true C++ compiler and stdlib exist. There is m$s$ C++ thats a different language from GNU C++. Look at all these plebians using windows... Signed-off-by: Arjo Chakravarty --- include/gz/transport/Discovery.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gz/transport/Discovery.hh b/include/gz/transport/Discovery.hh index b734a4858..d4de7b30f 100644 --- a/include/gz/transport/Discovery.hh +++ b/include/gz/transport/Discovery.hh @@ -788,7 +788,7 @@ namespace ignition sockaddr_in clntAddr; socklen_t addrLen = sizeof(clntAddr); - uint16_t received = recvfrom(this->sockets.at(0), + int64_t received = recvfrom(this->sockets.at(0), reinterpret_cast(rcvStr), this->kMaxRcvStr, 0, reinterpret_cast(&clntAddr), @@ -820,7 +820,7 @@ namespace ignition // unexpected size, then we ignore the message. // If-condition for version 8+ - if (len + sizeof(len) == received) + if (len + sizeof(len) == static_cast(received)) { std::string srcAddr = inet_ntoa(clntAddr.sin_addr); uint16_t srcPort = ntohs(clntAddr.sin_port);