VirtualBox

Changeset 32813 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Sep 29, 2010 11:50:19 AM (14 years ago)
Author:
vboxsync
Message:

VBoxService: Some division through zero checks.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceBalloon.cpp

    r32772 r32813  
    305305uint32_t VBoxServiceBalloonQueryPages(uint32_t cbPage)
    306306{
     307    Assert(cbPage > 0);
    307308    return g_cMemBalloonChunks * (VMMDEV_MEMORY_BALLOON_CHUNK_SIZE / cbPage);
    308309}
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp

    r32772 r32813  
    266266        deltaKernel          -= deltaIdle;  /* idle time is added to kernel time */
    267267        uint64_t ullTotalTime = deltaIdle + deltaKernel + deltaUser;
     268        if (ullTotalTime == 0) /* Prevent division through zero. */
     269            ullTotalTime = 1;
    268270
    269271        req.guestStats.u32CpuLoad_Idle      = (uint32_t)(deltaIdle  * 100 / ullTotalTime);
     
    412414                                            + u64DeltaUser
    413415                                            + u64DeltaNice;
     416                    if (u64DeltaAll == 0) /* Prevent division through zero. */
     417                        u64DeltaAll = 1;
    414418
    415419                    gCtx.au64LastCpuLoad_Idle[u32CpuId]   = u64Idle;
     
    507511                    if (rc != -1)
    508512                    {
     513                        Assert(SysInfo.updates != 0);
    509514                        u64PagedTotal = VMInfo.swap_avail / SysInfo.updates;
    510515                    }
     
    562567
    563568                uint64_t u64DeltaAll    = u64DeltaIdle + u64DeltaSystem + u64DeltaUser;
     569                if (u64DeltaAll == 0) /* Prevent division through zero. */
     570                    u64DeltaAll = 1;
    564571
    565572                gCtx.au64LastCpuLoad_Idle[cCPUs]   = u64Idle;
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