[SOLVED] Re: Cppcheck : Variable 'bRet' is reassigned a value in autoform.cxx
Julien Nabet
serval2412 at yahoo.fr
Sat Jan 19 01:14:34 PST 2013
On 18/01/2013 12:01, Caolán McNamara wrote:
> On Thu, 2013-01-17 at 13:54 -0800, julien2412 wrote:
>> What should we do with bRet value, after line 1102?
> bRet is supposed to return true if the save succeeded s
>
>
> a) changing all the bRets after the initial initialization from
>
> bRet = foo
> to
> bRet&= foo
>
> would ensure that the failed state of any check is kept
>
> b) alternatively, could change the
> bool bRet = ...
> if (bRet)
> {
> bRet = foo
> bRet = bar
> }
>
> to something like
>
> bool bRet = true;
> do
> {
> bRet = foo;
> if (!bRet)
> break;
>
> bRet = bar;
> if (!bRet)
> break;
>
> } while(0);
>
> c) just do one bRet = (rStream.GetError() == 0); before the Flush and
> remove the other ones inside the bRet block
>
>> Also, notice the line 1107 "++it" to skip the first item. Shouldn't we add a
>> wrapper if(it != itEnd) for the "for loop" to be sure?
> Yeah, I think you definitely should
Thank you again Caolán, I pushed a fix on master (see
http://cgit.freedesktop.org/libreoffice/core/commit/?id=c228103ce6a5efe60de553073a9b20d977478bf5)
Julien
More information about the LibreOffice
mailing list