Cppcheck: incorrectLogicOperator in svxrectctaccessiblecontext.cxx (in svx module)

Stephan Bergmann sbergman at redhat.com
Mon May 13 00:56:34 PDT 2013


On 05/12/2013 07:25 PM, julien2412 wrote:
> cppcheck reported this:
> <error file="svx/source/accessibility/svxrectctaccessiblecontext.cxx"
> line="612" id="incorrectLogicOperator" severity="style" msg="Logical
> disjunction always evaluates to true: nIndex >= 0 || nIndex < 0."/>
>
> Indeed we have in this file that:
>      610 void SvxRectCtlAccessibleContext::checkChildIndex( long nIndex )
> throw( lang::IndexOutOfBoundsException )
>      611 {
>      612     if( nIndex < 0 || nIndex >= getAccessibleChildCount() )
>      613         throw lang::IndexOutOfBoundsException();
>      614 }
>
> and that!
>      883 sal_Int32 SAL_CALL
> SvxRectCtlChildAccessibleContext::getAccessibleChildCount( void ) throw(
> RuntimeException )
>      884 {
>      885     return 0;
>      886 }
>
> And this last one is like this since 2002!
>
> What should be done here?

Unless Cppcheck does whole-program-analysis (does it?), this is a false 
positive.  SvxRectCtlAccessibleContext::getAccessibleChildCount is 
virtual, and from just looking at svxrectctaccessiblecontext.cxx one 
cannot determine that there cannot be any overrides of it.

Stephan


More information about the LibreOffice mailing list