Bugzilla – Bug 995
Useless (possibly incorrect) comparison of unsigned int
Last modified: 2010-12-28 19:44:39 UTC
Created attachment 977 [details] Proposed patch ../src/devices/wimax/simple-ofdm-wimax-phy.cc:800:3: error: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] NS_ASSERT_MSG (m_paddingBits >= 0, "Size of padding bytes < 0"); ~~~~~~~~~~~~~ ^ ~ Assertion can never fail - should make the assertion on the subtraction instead of the final value (which is silently cast back to uint. ----- ../src/devices/wimax/bs-scheduler-simple.cc:168:35: error: ][0.820s] comparison of unsigned expression >= 0 is always true [-Wtautological-compare] while (availableSymbols >= 0 && ... ~~~~~~~~~~~~~~~~ ^ ~ For this one, lines 193-196 may not trigger if availableSymbols overflows. Lines 162 may cause the overflow. The else-block at line 166 cannot overflow - no code branch can decrease availableSymbols to below 0. The 1st while condition on line 168 can therefore be removed. ----- ../src/devices/wimax/wimax-mac-queue.cc:175:11: error: comparison of unsigned expression >= 0 is always true [-Wtautological-compare] NS_ASSERT_MSG (m_nrDataPackets >= 0, ~~~~~~~~~~~~~~~ ^ ~ (Also on line 182) Need to swap the decrement operation and the assertion (catch error before overflow)
Created attachment 978 [details] Proposed patch
Proposed patch applied.