[Nut-upsdev] nut-2.6.5:rhino.c:190: bad if test ?
Charles Lepple
clepple at gmail.com
Tue Oct 8 12:52:01 UTC 2013
On Oct 8, 2013, at 4:30 AM, David Binderman wrote:
> Hello there,
>
> Offending source code is
>
> if( ( BattVoltage> 129 ) || ( BattVoltage < 144 ) )
>
> Maybe swap || for && would be better.
That does make sense.
Silvino, can you confirm that swapping || for && still works on Rhino hardware? (The AutonomyCalc() function has a lot of magic numbers, so I don't want to make assumptions.
> This problem I found by using cppcheck. It said
>
> [rhino.c:190]: (warning) Logical disjunction always evaluates to true: BattVoltage> 129 || BattVoltage < 144.
Interesting that clang did not warn about that - maybe we should add cppcheck to our Buildbot setup, too.
--
Charles Lepple
clepple at gmail
More information about the Nut-upsdev
mailing list