VirtualBox

Changeset 84475 in vbox for trunk/src


Ignore:
Timestamp:
May 23, 2020 5:32:19 PM (5 years ago)
Author:
vboxsync
Message:

VDI: shut up paranoid VCC 14.2 6.6.0 warnings about potential div-by-zero. bugref:8489

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VDI.cpp

    r82968 r84475  
    25682568    {
    25692569        unsigned cBlocksAllocated = getImageBlocksAllocated(&pImage->Header); /** < Blocks currently allocated, doesn't change during resize */
    2570         uint32_t cBlocksNew = cbSize / getImageBlockSize(&pImage->Header);    /** < New number of blocks in the image after the resize */
    2571         if (cbSize % getImageBlockSize(&pImage->Header))
     2570        unsigned const cbBlock = RT_MAX(getImageBlockSize(&pImage->Header), 1);
     2571        uint32_t cBlocksNew = cbSize / cbBlock;                               /** < New number of blocks in the image after the resize */
     2572        if (cbSize % cbBlock)
    25722573            cBlocksNew++;
    25732574
     
    25822583                /* Calculate how many sectors need to be relocated. */
    25832584                uint64_t cbOverlapping = offStartDataNew - pImage->offStartData;
    2584                 unsigned cBlocksReloc = cbOverlapping / getImageBlockSize(&pImage->Header);
    2585                 if (cbOverlapping % getImageBlockSize(&pImage->Header))
     2585                unsigned cBlocksReloc = cbOverlapping / cbBlock;
     2586                if (cbOverlapping % cbBlock)
    25862587                    cBlocksReloc++;
    25872588
     
    27992800        if (IS_VDI_IMAGE_BLOCK_ALLOCATED(pImage->paBlocks[uBlock]))
    28002801        {
     2802            unsigned const cbBlock = RT_MAX(getImageBlockSize(&pImage->Header), 1);
     2803            size_t const cbPreAllocated = offDiscard % cbBlock;
     2804            size_t const cbPostAllocated = getImageBlockSize(&pImage->Header) - cbDiscard - cbPreAllocated;
    28012805            uint8_t *pbBlockData;
    2802             size_t cbPreAllocated, cbPostAllocated;
    2803 
    2804             cbPreAllocated = offDiscard % getImageBlockSize(&pImage->Header);
    2805             cbPostAllocated = getImageBlockSize(&pImage->Header) - cbDiscard - cbPreAllocated;
    28062806
    28072807            /* Read the block data. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette