Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


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 ?


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.