Skip to content

Commit

Permalink
Fix -Wtype-limits warnings and remove disabling of -Wtype-limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno- committed Dec 29, 2014
1 parent 5038b9a commit 3993102
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
5 changes: 0 additions & 5 deletions src/CMakeLists.txt
Expand Up @@ -643,11 +643,6 @@ else()
if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)

CHECK_CXX_COMPILER_FLAG("-Wno-type-limits" HAS_TYPE_LIMITS_WARNING)
if(HAS_TYPE_LIMITS_WARNING)
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-type-limits")
endif(HAS_TYPE_LIMITS_WARNING)
endif()

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down
19 changes: 10 additions & 9 deletions src/connection.cpp
Expand Up @@ -2334,15 +2334,19 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,

u8 type = readU8(&(packetdata[0]));

if (MAX_UDP_PEERS <= 65535 && peer_id >= MAX_UDP_PEERS) {
errorstream << "Something is wrong with peer_id" << std::endl;
assert(0);
}

if(type == TYPE_CONTROL)
{
if(packetdata.getSize() < 2)
throw InvalidIncomingDataException("packetdata.getSize() < 2");

u8 controltype = readU8(&(packetdata[1]));

if( (controltype == CONTROLTYPE_ACK)
&& (peer_id <= MAX_UDP_PEERS))
if(controltype == CONTROLTYPE_ACK)
{
assert(channel != 0);
if(packetdata.getSize() < 4)
Expand Down Expand Up @@ -2399,8 +2403,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
}
throw ProcessedSilentlyException("Got an ACK");
}
else if((controltype == CONTROLTYPE_SET_PEER_ID)
&& (peer_id <= MAX_UDP_PEERS))
else if(controltype == CONTROLTYPE_SET_PEER_ID)
{
// Got a packet to set our peer id
if(packetdata.getSize() < 4)
Expand Down Expand Up @@ -2432,8 +2435,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,

throw ProcessedSilentlyException("Got a SET_PEER_ID");
}
else if((controltype == CONTROLTYPE_PING)
&& (peer_id <= MAX_UDP_PEERS))
else if(controltype == CONTROLTYPE_PING)
{
// Just ignore it, the incoming data already reset
// the timeout counter
Expand All @@ -2455,8 +2457,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,

throw ProcessedSilentlyException("Got a DISCO");
}
else if((controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
&& (peer_id <= MAX_UDP_PEERS))
else if(controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
{
dynamic_cast<UDPPeer*>(&peer)->setNonLegacyPeer();
throw ProcessedSilentlyException("Got non legacy control");
Expand Down Expand Up @@ -2514,7 +2515,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
//TODO throw some error
}
}
else if((peer_id <= MAX_UDP_PEERS) && (type == TYPE_RELIABLE))
else if(type == TYPE_RELIABLE)
{
assert(channel != 0);
// Recursive reliable packets not allowed
Expand Down
6 changes: 5 additions & 1 deletion src/map.cpp
Expand Up @@ -1766,7 +1766,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
content_t new_node_content;
s8 new_node_level = -1;
s8 max_node_level = -1;
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);

u8 range = nodemgr->get(liquid_kind).liquid_range;
if (range > LIQUID_LEVEL_MAX+1)
range = LIQUID_LEVEL_MAX+1;

if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
// or the flowing alternative of the first of the surrounding sources (if it's air), so
Expand Down
4 changes: 3 additions & 1 deletion src/serialization.h
Expand Up @@ -72,7 +72,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Lowest supported serialization version
#define SER_FMT_VER_LOWEST 0

#define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ)
inline bool ser_ver_supported(s32 v) {
return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
}

/*
Misc. serialization functions
Expand Down
2 changes: 1 addition & 1 deletion src/server.cpp
Expand Up @@ -1361,7 +1361,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
u8 client_max = data[2];
u8 our_max = SER_FMT_VER_HIGHEST_READ;
// Use the highest version supported by both
u8 deployed = std::min(client_max, our_max);
int deployed = std::min(client_max, our_max);
// If it's lower than the lowest supported, give up.
if(deployed < SER_FMT_VER_LOWEST)
deployed = SER_FMT_VER_INVALID;
Expand Down
2 changes: 1 addition & 1 deletion src/tile.cpp
Expand Up @@ -1859,7 +1859,7 @@ void imageTransform(u32 transform, video::IImage *src, video::IImage *dst)
core::dimension2d<u32> dstdim = dst->getDimension();

assert(dstdim == imageTransformDimension(transform, srcdim));
assert(transform >= 0 && transform <= 7);
assert(transform <= 7);

/*
Compute the transformation from source coordinates (sx,sy)
Expand Down

0 comments on commit 3993102

Please sign in to comment.