Cppcheck reports "Logical disjunction always evaluates to true" in sdext module

julien2412 serval2412 at yahoo.fr
Sun Mar 18 10:24:42 PDT 2012


Hello,

Cppcheck reports this in sdext module :
[source/minimizer/optimizerdialog.cxx:276]: (warning) Logical disjunction
always evaluates to true: nNewStep >= 0 || nNewStep <= 4
Here is the line :
if ( ( nNewStep != mnCurrentStep ) && ( ( nNewStep <= MAX_STEP ) || (
nNewStep >= 0 ) ) )

Shouldn't it be :
if ( ( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep
>= 0 ) )
?
Moreover, if I'm right, should we additionnally throw an exception (which
one ?) if "nNewStep" is not between 0 and MAX_STEP 

If ok for just the condition change, I can commit and push on master (what
about 3.5 ?)
About the exception, I don't know what to put.

Julien.

--
View this message in context: http://nabble.documentfoundation.org/Cppcheck-reports-Logical-disjunction-always-evaluates-to-true-in-sdext-module-tp3836919p3836919.html
Sent from the Dev mailing list archive at Nabble.com.


More information about the LibreOffice mailing list