Cppcheck : Variable 'nMode' is reassigned in fstat.cxx

Stephan Bergmann sbergman at redhat.com
Mon Jan 21 02:48:45 PST 2013


On 01/19/2013 05:35 PM, julien2412 wrote:
> Cppcheck reported this:
> <error file="tools/source/fsys/fstat.cxx" line="112"
> id="redundantAssignment" severity="style" msg="Variable 'nMode' is
> reassigned a value before the old one has been used."/>
> <error file="tools/source/fsys/fstat.cxx" line="113"
> id="redundantAssignment" severity="style" msg="Variable 'nMode' is
> reassigned a value before the old one has been used."/>
>
> Indeed, we can see this:
>      109     if (bRO)
>      110     {
>      111         nMode = aBuf.st_mode & ~S_IWUSR;
>      112         nMode = aBuf.st_mode & ~S_IWGRP;
>      113         nMode = aBuf.st_mode & ~S_IWOTH;
>      114     }

This apparently wants to remove all the write permission bits from the 
following chmod call, so should better read

   nMode = aBuf.st_mode & ~(S_IWUSR | S_IWGRP | S_IWOTH);

Stephan


More information about the LibreOffice mailing list