diff -r 67ee979a1807 examples/routing/manet-routing-compare.cc --- a/examples/routing/manet-routing-compare.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/examples/routing/manet-routing-compare.cc Sun Apr 20 08:20:40 2014 -0700 @@ -343,7 +343,7 @@ onoff1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]")); onoff1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]")); - for (int i = 0; i <= nSinks - 1; i++) + for (int i = 0; nSinks - i > 0; i++) { Ptr sink = SetupPacketReceive (adhocInterfaces.GetAddress (i), adhocNodes.Get (i)); diff -r 67ee979a1807 src/lte/model/cqa-ff-mac-scheduler.cc --- a/src/lte/model/cqa-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/cqa-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1963,7 +1963,7 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ((!allocated)&&((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) && (rbPerFlow != 0)) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/fdbet-ff-mac-scheduler.cc --- a/src/lte/model/fdbet-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/fdbet-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1593,7 +1593,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/fdmt-ff-mac-scheduler.cc --- a/src/lte/model/fdmt-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/fdmt-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1571,7 +1571,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/fdtbfq-ff-mac-scheduler.cc --- a/src/lte/model/fdtbfq-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/fdtbfq-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1822,7 +1822,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/lte-enb-rrc.cc --- a/src/lte/model/lte-enb-rrc.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/lte-enb-rrc.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1041,7 +1041,7 @@ { NS_LOG_FUNCTION (this); const uint8_t MAX_DRB_ID = 32; - for (uint8_t drbid = (m_lastAllocatedDrbid + 1) % MAX_DRB_ID; + for (int drbid = (m_lastAllocatedDrbid + 1) % MAX_DRB_ID; drbid != m_lastAllocatedDrbid; drbid = (drbid + 1) % MAX_DRB_ID) { diff -r 67ee979a1807 src/lte/model/lte-rlc-sequence-number.h --- a/src/lte/model/lte-rlc-sequence-number.h Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/lte-rlc-sequence-number.h Sun Apr 20 08:20:40 2014 -0700 @@ -78,7 +78,7 @@ SequenceNumber10 operator++ (int) { SequenceNumber10 retval (m_value); - m_value = (m_value + 1) % 1024; + m_value = ((uint32_t)m_value + 1) % 1024; return retval; } diff -r 67ee979a1807 src/lte/model/pf-ff-mac-scheduler.cc --- a/src/lte/model/pf-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/pf-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1617,7 +1617,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/pss-ff-mac-scheduler.cc --- a/src/lte/model/pss-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/pss-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1922,7 +1922,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/rr-ff-mac-scheduler.cc --- a/src/lte/model/rr-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/rr-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1454,7 +1454,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/tdbet-ff-mac-scheduler.cc --- a/src/lte/model/tdbet-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/tdbet-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1515,7 +1515,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/tdmt-ff-mac-scheduler.cc --- a/src/lte/model/tdmt-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/tdmt-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1511,7 +1511,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/tdtbfq-ff-mac-scheduler.cc --- a/src/lte/model/tdtbfq-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/tdtbfq-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1609,7 +1609,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/lte/model/tta-ff-mac-scheduler.cc --- a/src/lte/model/tta-ff-mac-scheduler.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/lte/model/tta-ff-mac-scheduler.cc Sun Apr 20 08:20:40 2014 -0700 @@ -1590,7 +1590,10 @@ uldci.m_rbLen = rbPerFlow; bool allocated = false; NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows); - while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0)) + while ( (!allocated) && + (rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth < 1) && + (rbPerFlow != 0) + ) { // check availability bool free = true; diff -r 67ee979a1807 src/network/model/address.cc --- a/src/network/model/address.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/network/model/address.cc Sun Apr 20 08:20:40 2014 -0700 @@ -90,7 +90,7 @@ Address::CopyAllTo (uint8_t *buffer, uint8_t len) const { NS_LOG_FUNCTION (this << &buffer << static_cast (len)); - NS_ASSERT (len >= m_len + 2); + NS_ASSERT ((int)len - m_len > 1); buffer[0] = m_type; buffer[1] = m_len; std::memcpy (buffer + 2, m_data, m_len); @@ -114,7 +114,7 @@ m_type = buffer[0]; m_len = buffer[1]; - NS_ASSERT (len >= m_len + 2); + NS_ASSERT ((int)len - m_len > 1); std::memcpy (m_data, buffer + 2, m_len); return m_len + 2; } diff -r 67ee979a1807 src/network/utils/ipv6-address.cc --- a/src/network/utils/ipv6-address.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/network/utils/ipv6-address.cc Sun Apr 20 08:20:40 2014 -0700 @@ -154,7 +154,7 @@ static const char xdigits_u[] = "0123456789ABCDEF"; unsigned char tmp[16]; unsigned char* tp = tmp; - unsigned char* endp = 0; + unsigned char* const endp = tp + 16; unsigned char* colonp = 0; const char* xdigits = 0; #if 0 @@ -165,7 +165,6 @@ unsigned int val = 0; memset (tp, 0x00, 16); - endp = tp + 16; /* Leading :: requires some special handling. */ if (*address == ':') @@ -212,7 +211,7 @@ continue; } - if (tp + 2 > endp) + if (endp - tp < 2) { return (0); } @@ -226,7 +225,7 @@ /* \todo Handle IPv4 mapped address (2001::192.168.0.1) */ #if 0 - if (ch == '.' && ((tp + 4 /*NS_INADDRSZ*/) <= endp) && + if (ch == '.' && (endp - tp > 3 /*NS_INADDRSZ*/)) && inet_pton4 (curtok, tp) > 0) { tp += 4 /*NS_INADDRSZ*/; @@ -239,7 +238,7 @@ if (seen_xdigits) { - if (tp + 2 > endp) + if ( endp - tp < 2) { return (0); } diff -r 67ee979a1807 src/network/utils/packetbb.cc --- a/src/network/utils/packetbb.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/network/utils/packetbb.cc Sun Apr 20 08:20:40 2014 -0700 @@ -2516,7 +2516,7 @@ } /* If headlen == fulllen - 1, then tail is 0 */ - if (headlen <= GetAddressLength () - 1) + if (GetAddressLength () - (int)headlen > 0) { for (i = GetAddressLength () - 1; GetAddressLength () - 1 - i <= taillen && i > headlen; diff -r 67ee979a1807 src/wimax/model/cid-factory.cc --- a/src/wimax/model/cid-factory.cc Tue Apr 08 14:07:33 2014 -0700 +++ b/src/wimax/model/cid-factory.cc Sun Apr 20 08:20:40 2014 -0700 @@ -99,13 +99,13 @@ CidFactory::IsTransport (Cid cid) const { uint16_t id = cid.m_identifier; - return id >= 2 * m_m + 1 && id <= 0xfefe; + return ((int)id - 2 * (int)m_m > 0) && (id <= 0xfefe); } bool CidFactory::IsPrimary (Cid cid) const { uint16_t id = cid.m_identifier; - return id >= m_m + 1 && id <= 2 * m_m; + return ((int)id - m_m > 0) && (id <= 2 * m_m); } bool CidFactory::IsBasic (Cid cid) const diff -r 67ee979a1807 wscript --- a/wscript Tue Apr 08 14:07:33 2014 -0700 +++ b/wscript Sun Apr 20 08:20:40 2014 -0700 @@ -325,6 +325,8 @@ if Options.options.build_profile == 'optimized': if conf.check_compilation_flag('-march=native'): env.append_value('CXXFLAGS', '-march=native') + env.append_value('CXXFLAGS', '-fstrict-overflow') + env.append_value('CXXFLAGS', '-Wstrict-overflow=5') if sys.platform == 'win32': env.append_value("LINKFLAGS", "-Wl,--enable-runtime-pseudo-reloc")