Skip to content

Commit

Permalink
Fix compiler warning and signedness issue (#401)
Browse files Browse the repository at this point in the history
* 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 <arjoc@intrinsic.ai>

* 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 <arjoc@intrinsic.ai>
  • Loading branch information
arjo129 authored Jun 1, 2023
1 parent a95b593 commit dcb737f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/gz/transport/Discovery.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<raw_type *>(rcvStr),
this->kMaxRcvStr, 0,
reinterpret_cast<sockaddr *>(&clntAddr),
Expand Down Expand Up @@ -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<uint16_t>(received))
{
std::string srcAddr = inet_ntoa(clntAddr.sin_addr);
uint16_t srcPort = ntohs(clntAddr.sin_port);
Expand Down

1 comment on commit dcb737f

@arjo129
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message in commit a9f5d82 is inappropriate and unprofessional and goes against the core Gazebo values. I did not mean to insult or disparage any users of windows (I myself being one every now and then) or the company behind it. I sincerely apologize for this lapse of judgment and will be more careful in the language used in my future commits.

Please sign in to comment.