[Libreoffice] Questions about ./sdext/source/minimizer/unodialog.cxx

julien serval2412 at yahoo.fr
Sun Nov 7 05:00:36 PST 2010


Hello,

I'm currently running a cppcheck on the clone directory (i had try to 
launch cppcheck on the build/libreoffice... but it seemed it freezed).
I've seen this issue :
[./extensions/sdext/source/minimizer/unodialog.cxx:359]: (error) 
Division by zero

I opened the file and saw this :
sal_Int32 UnoDialog::getMapsFromPixels( sal_Int32 nPixels ) const
{
     double dMaps = 0;
     try
     {
         sal_Int32 nMapWidth = 0;
         const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
         if ( mxDialogModelPropertySet->getPropertyValue( sWidth  ) >>= 
nMapWidth )
         {
             Reference< XWindow > xWindow( mxDialog, UNO_QUERY_THROW );
             double pxWidth = xWindow->getPosSize().Width;
             double mapRatio = ( pxWidth / nMapWidth ); ------- HERE IS 
THE DIVSION BY ZERO DETECTED BY CPPCHECK
             dMaps = nPixels / mapRatio;
         }
     }
     catch ( Exception& )
     {
     }
     return static_cast< sal_Int32 >( dMaps );
}

Questions :
- what's the use of nMapWidth since it's initialized to 0 and stays at 
this value ?
- What's the use of making a right rotation of bits of 0 ? 
(mxDialogModelPropertySet->getPropertyValue( sWidth  ) >>= nMapWidth)
- what's the use of a catch with nothing in it except for hidding a bug ?



More information about the LibreOffice mailing list