Hello, Cppcheck reported this: 468 variableScope style The scope of the variable 'bRdFlag' can be reduced.
Indeed: (see http://opengrok.libreoffice.org/xref/core/vcl/source/filter/sgfbram.cxx#460) 462 bool SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf) 463 { 464 sal_uLong nFileStart; // Offset des SgfHeaders. Im allgemeinen 0. 465 SgfHeader aHead; 466 SgfEntry aEntr; 467 sal_uLong nNext; 468 bool bRdFlag=false; // Grafikentry gelesen ? 469 bool bRet=false; // Returncode 470 471 nFileStart=rInp.Tell(); 472 rInp>>aHead; 473 if (aHead.ChkMagic() && aHead.Typ==SGF_SIMPVECT) { 474 nNext=aHead.GetOffset(); 475 while (nNext && !bRdFlag && !rInp.GetError()) { 476 rInp.Seek(nFileStart+nNext); 477 rInp>>aEntr; 478 nNext=aEntr.GetOffset(); 479 if (aEntr.Typ==aHead.Typ) { 480 bRet=SgfFilterVect(rInp,aHead,aEntr,rMtf); 481 } 482 } // while(nNext) 483 if (bRdFlag) { 484 if (!rInp.GetError()) bRet=true; // Scheinbar Ok 485 } 486 } 487 return(bRet); But bRdFlag is never updated so we never pass in l484 and, above all, the while loop line 475 keeps on. If we take the example above (see http://opengrok.libreoffice.org/xref/core/vcl/source/filter/sgfbram.cxx#326) 326 bool SgfBMapFilter(SvStream& rInp, SvStream& rOut) 327 { 328 sal_uLong nFileStart; // Offset des SgfHeaders. Im allgemeinen 0. 329 SgfHeader aHead; 330 SgfEntry aEntr; 331 sal_uLong nNext; 332 bool bRdFlag=false; // Grafikentry gelesen ? 333 bool bRet=false; // Returncode 334 335 nFileStart=rInp.Tell(); 336 rInp>>aHead; 337 if (aHead.ChkMagic() && (aHead.Typ==SgfBitImag0 || aHead.Typ==SgfBitImag1 || 338 aHead.Typ==SgfBitImag2 || aHead.Typ==SgfBitImgMo)) { 339 nNext=aHead.GetOffset(); 340 while (nNext && !bRdFlag && !rInp.GetError() && !rOut.GetError()) { 341 rInp.Seek(nFileStart+nNext); 342 rInp>>aEntr; 343 nNext=aEntr.GetOffset(); 344 if (aEntr.Typ==aHead.Typ) { 345 bRdFlag=true; 346 switch(aEntr.Typ) { 347 case SgfBitImag0: 348 case SgfBitImag1: 349 case SgfBitImag2: 350 case SgfBitImgMo: bRet=SgfFilterBMap(rInp,rOut,aHead,aEntr); break; 351 } 352 } 353 } // while(nNext) 354 } 355 if (rInp.GetError()) bRet=false; 356 return(bRet); 357 } bRdFlag is put at true line 345. So what about get rid of bRdFlag and put some breaks instead + test GetError at the end for both? it should give this patch: diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx index 8c4a6ad..8079f27 100644 --- a/vcl/source/filter/sgfbram.cxx +++ b/vcl/source/filter/sgfbram.cxx @@ -329,7 +329,6 @@ bool SgfBMapFilter(SvStream& rInp, SvStream& rOut) SgfHeader aHead; SgfEntry aEntr; sal_uLong nNext; - bool bRdFlag=false; // Grafikentry gelesen ? bool bRet=false; // Returncode nFileStart=rInp.Tell(); @@ -337,12 +336,11 @@ bool SgfBMapFilter(SvStream& rInp, SvStream& rOut) if (aHead.ChkMagic() && (aHead.Typ==SgfBitImag0 || aHead.Typ==SgfBitImag1 || aHead.Typ==SgfBitImag2 || aHead.Typ==SgfBitImgMo)) { nNext=aHead.GetOffset(); - while (nNext && !bRdFlag && !rInp.GetError() && !rOut.GetError()) { + while (nNext && !rInp.GetError() && !rOut.GetError()) { rInp.Seek(nFileStart+nNext); rInp>>aEntr; nNext=aEntr.GetOffset(); if (aEntr.Typ==aHead.Typ) { - bRdFlag=true; switch(aEntr.Typ) { case SgfBitImag0: case SgfBitImag1: @@ -465,25 +463,23 @@ bool SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf) SgfHeader aHead; SgfEntry aEntr; sal_uLong nNext; - bool bRdFlag=false; // Grafikentry gelesen ? bool bRet=false; // Returncode nFileStart=rInp.Tell(); rInp>>aHead; if (aHead.ChkMagic() && aHead.Typ==SGF_SIMPVECT) { nNext=aHead.GetOffset(); - while (nNext && !bRdFlag && !rInp.GetError()) { + while (nNext && !rInp.GetError()) { rInp.Seek(nFileStart+nNext); rInp>>aEntr; nNext=aEntr.GetOffset(); if (aEntr.Typ==aHead.Typ) { bRet=SgfFilterVect(rInp,aHead,aEntr,rMtf); + break; } } // while(nNext) - if (bRdFlag) { - if (!rInp.GetError()) bRet=true; // Scheinbar Ok - } }-- + if (rInp.GetError()) bRet=false; return(bRet); } Julien -- View this message in context: http://nabble.documentfoundation.org/About-bRdFlag-in-SgfVectFilter-method-vcl-module-tp4077705.html Sent from the Dev mailing list archive at Nabble.com. _______________________________________________ LibreOffice mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice
