Don't assume char to be unsigned when generating packet header

OR'ing an enum value and a char with its highest bit set sign-extends the char.
On compilers with signed chars, this means you end up with a negative integer,
which can't be narrowed to uint8_t at initialization (which is what PacketHdr's
first member is).
stable-5.3 v5.3.2
Nicolas Hake 2012-11-17 22:53:56 +01:00
parent ed971eba46
commit 7a13be20e8
1 changed files with 1 additions and 1 deletions

View File

@ -1885,7 +1885,7 @@ bool C4NetIOUDP::InitBroadcast(addr_t *pBroadcastAddr)
return false;
}
// send a ping packet
const PacketHdr PingPacket = { IPID_Ping | char(0x80), 0 };
const PacketHdr PingPacket = { IPID_Ping | static_cast<uint8_t>(0x80u), 0 };
if (!C4NetIOSimpleUDP::Broadcast(C4NetIOPacket(&PingPacket, sizeof(PingPacket))))
{
C4NetIOSimpleUDP::CloseBroadcast();