Skip to content

Commit 3993102

Browse files
committedDec 29, 2014
Fix -Wtype-limits warnings and remove disabling of -Wtype-limits
1 parent 5038b9a commit 3993102

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed
 

‎src/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,6 @@ else()
643643
if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
644644
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
645645
endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
646-
647-
CHECK_CXX_COMPILER_FLAG("-Wno-type-limits" HAS_TYPE_LIMITS_WARNING)
648-
if(HAS_TYPE_LIMITS_WARNING)
649-
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-type-limits")
650-
endif(HAS_TYPE_LIMITS_WARNING)
651646
endif()
652647

653648
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

‎src/connection.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -2334,15 +2334,19 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
23342334

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

2337+
if (MAX_UDP_PEERS <= 65535 && peer_id >= MAX_UDP_PEERS) {
2338+
errorstream << "Something is wrong with peer_id" << std::endl;
2339+
assert(0);
2340+
}
2341+
23372342
if(type == TYPE_CONTROL)
23382343
{
23392344
if(packetdata.getSize() < 2)
23402345
throw InvalidIncomingDataException("packetdata.getSize() < 2");
23412346

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

2344-
if( (controltype == CONTROLTYPE_ACK)
2345-
&& (peer_id <= MAX_UDP_PEERS))
2349+
if(controltype == CONTROLTYPE_ACK)
23462350
{
23472351
assert(channel != 0);
23482352
if(packetdata.getSize() < 4)
@@ -2399,8 +2403,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
23992403
}
24002404
throw ProcessedSilentlyException("Got an ACK");
24012405
}
2402-
else if((controltype == CONTROLTYPE_SET_PEER_ID)
2403-
&& (peer_id <= MAX_UDP_PEERS))
2406+
else if(controltype == CONTROLTYPE_SET_PEER_ID)
24042407
{
24052408
// Got a packet to set our peer id
24062409
if(packetdata.getSize() < 4)
@@ -2432,8 +2435,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
24322435

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

24562458
throw ProcessedSilentlyException("Got a DISCO");
24572459
}
2458-
else if((controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
2459-
&& (peer_id <= MAX_UDP_PEERS))
2460+
else if(controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
24602461
{
24612462
dynamic_cast<UDPPeer*>(&peer)->setNonLegacyPeer();
24622463
throw ProcessedSilentlyException("Got non legacy control");
@@ -2514,7 +2515,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
25142515
//TODO throw some error
25152516
}
25162517
}
2517-
else if((peer_id <= MAX_UDP_PEERS) && (type == TYPE_RELIABLE))
2518+
else if(type == TYPE_RELIABLE)
25182519
{
25192520
assert(channel != 0);
25202521
// Recursive reliable packets not allowed

‎src/map.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
17661766
content_t new_node_content;
17671767
s8 new_node_level = -1;
17681768
s8 max_node_level = -1;
1769-
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
1769+
1770+
u8 range = nodemgr->get(liquid_kind).liquid_range;
1771+
if (range > LIQUID_LEVEL_MAX+1)
1772+
range = LIQUID_LEVEL_MAX+1;
1773+
17701774
if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
17711775
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
17721776
// or the flowing alternative of the first of the surrounding sources (if it's air), so

‎src/serialization.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
7272
// Lowest supported serialization version
7373
#define SER_FMT_VER_LOWEST 0
7474

75-
#define ser_ver_supported(v) (v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ)
75+
inline bool ser_ver_supported(s32 v) {
76+
return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
77+
}
7678

7779
/*
7880
Misc. serialization functions

‎src/server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
13611361
u8 client_max = data[2];
13621362
u8 our_max = SER_FMT_VER_HIGHEST_READ;
13631363
// Use the highest version supported by both
1364-
u8 deployed = std::min(client_max, our_max);
1364+
int deployed = std::min(client_max, our_max);
13651365
// If it's lower than the lowest supported, give up.
13661366
if(deployed < SER_FMT_VER_LOWEST)
13671367
deployed = SER_FMT_VER_INVALID;

‎src/tile.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,7 @@ void imageTransform(u32 transform, video::IImage *src, video::IImage *dst)
18591859
core::dimension2d<u32> dstdim = dst->getDimension();
18601860

18611861
assert(dstdim == imageTransformDimension(transform, srcdim));
1862-
assert(transform >= 0 && transform <= 7);
1862+
assert(transform <= 7);
18631863

18641864
/*
18651865
Compute the transformation from source coordinates (sx,sy)

0 commit comments

Comments
 (0)
Please sign in to comment.