Cppcheck reports 'else if' condition matches previous condition (svx)

Julien Nabet serval2412 at yahoo.fr
Tue Apr 8 11:58:21 PDT 2014


On 08/04/2014 13:10, Caolán McNamara wrote:
> On Sat, 2014-04-05 at 15:51 -0700, julien2412 wrote:
>> Hello,
>>
>> Cppcheck reported this
>> svx/source/unodraw/unomod.cxx
>> 492	multiCondition	style	Expression is always false because 'else if'
>> condition matches previous condition at line 460.
>>
>> Remark: It's a new kind of cppcheck detection and there are quite a lot of
>> false positives (at least for LO) for the moment.
>>
>> Here's the code:
>>      460         else if( aTypeName.startsWith( "TableShape" ) )
>>      461         {
>>      462             nType = OBJ_OLE2;
>>      463         }
>> ...
>>      492         else if( aTypeName.startsWith( "TableShape" ) )
>>      493         {
>>      494             nType = OBJ_TABLE;
>>      495         }
>>
>> see
>> http://opengrok.libreoffice.org/xref/core/svx/source/unodraw/unomod.cxx#460
>>
>> Which one of this block is ok?
> I rather think the second one is the correct one, seeing as
> svx/source/unodraw/unopage.cxx maps TableShape to OBJ_TABLE as well.
>
> At one point tables in impress/draw were embedded calc spreadsheets, and
> now they are "real" SdrObject things to that would also make sense.
>
> On the other hand that will change the current situation and I have no
> idea what makes the code enter that method so definitely a make check
> case at least :-)
I've just pushed the fix on master. "make check" on top level was ok.
Searching in git history during "make check", I found this commit from 2008:
http://cgit.freedesktop.org/libreoffice/core/commit/?id=5d20a47c3d50d0a88543b2355ec7340fc7455984
which references "OBJ_TABLE"
whereas OBJ_OLE2 was in 2001 (see 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=e24bc241b69da6789351d9bf82eab5119f09c16c) 


I submitted a gerrit review 4.2:
https://gerrit.libreoffice.org/8897

Julien


More information about the LibreOffice mailing list