Advice needed about some cppcheck reports

Stephan Bergmann sbergman at redhat.com
Wed May 30 01:04:05 PDT 2012


On 05/28/2012 06:03 PM, julien2412 wrote:
> [sal/osl/unx/file.cxx:1261] ->  [sal/osl/unx/file.cxx:1261]: (style) Same
> expression on both sides of '-'.
>     1257             if (nSize>  0)
>     1258             {
>     1259                 c^= pData[0];
>     1260                 pData += nSize;
>     1261                 nSize -= nSize;
>     1262             }
> Just put nSize to 0 ?
>
> Same thing here :
> [sal/osl/w32/file.cxx:880] ->  [sal/osl/w32/file.cxx:880]: (style) Same
> expression on both sides of '-'.
>      876         if (nSize>  0)
>      877         {
>      878             c ^= pData[0];
>      879             pData += nSize;
>      880             nSize -= nSize;
>      881         }

In both of the above cases, the updates of both pData and nSize can be 
removed completely from these "overspill" if-blocks, as the variables 
are not used any more afterwards.

>
> And here :
> [filter/source/graphicfilter/icgm/cgm.cxx:269] ->
> [filter/source/graphicfilter/icgm/cgm.cxx:269]: (style) Same expression on
> both sides of '-'.
>      267             if ( pLong[ nSwitch ]<  0 )
>      268             {
>      269                 nRetValue -= nRetValue;
>      270             }
>      271             nRetValue /= 65536;

I'd second Lubos here, that from looking at just the code in 
CGM::ImplGetFloat (but not understanding any of the context), "nRetValue 
= -nRetValue" is most likely what is meant instead.

Stephan


More information about the LibreOffice mailing list