VirtualBox

Changeset 14064 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Nov 10, 2008 11:27:40 PM (16 years ago)
Author:
vboxsync
Message:

fileio-win.cpp: shut up 64-bit MSC warnings (valid ones this time).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r13837 r14064  
    357357    if (cbToRead <= 0)
    358358        return VINF_SUCCESS;
     359    ULONG cbToReadAdj = (ULONG)cbToRead;
     360    AssertReturn(cbToReadAdj == cbToRead, VERR_NUMBER_TOO_BIG);
    359361
    360362    ULONG cbRead = 0;
    361     if (ReadFile((HANDLE)File, pvBuf, cbToRead, &cbRead, NULL))
     363    if (ReadFile((HANDLE)File, pvBuf, cbToReadAdj, &cbRead, NULL))
    362364    {
    363365        if (pcbRead)
     
    367369        {
    368370            /* Caller expects everything to be read. */
    369             while (cbToRead > cbRead)
     371            while (cbToReadAdj > cbRead)
    370372            {
    371373                ULONG cbReadPart = 0;
    372                 if (!ReadFile((HANDLE)File, (char*)pvBuf + cbRead, cbToRead - cbRead, &cbReadPart, NULL))
     374                if (!ReadFile((HANDLE)File, (char*)pvBuf + cbRead, cbToReadAdj - cbRead, &cbReadPart, NULL))
    373375                    return RTErrConvertFromWin32(GetLastError());
    374376                if (cbReadPart == 0)
     
    387389    if (cbToWrite <= 0)
    388390        return VINF_SUCCESS;
     391    ULONG cbToWriteAdj = (ULONG)cbToWrite;
     392    AssertReturn(cbToWriteAdj == cbToWrite, VERR_NUMBER_TOO_BIG);
    389393
    390394    ULONG cbWritten = 0;
    391     if (WriteFile((HANDLE)File, pvBuf, cbToWrite, &cbWritten, NULL))
     395    if (WriteFile((HANDLE)File, pvBuf, cbToWriteAdj, &cbWritten, NULL))
    392396    {
    393397        if (pcbWritten)
     
    397401        {
    398402            /* Caller expects everything to be written. */
    399             while (cbToWrite > cbWritten)
     403            while (cbToWriteAdj > cbWritten)
    400404            {
    401405                ULONG cbWrittenPart = 0;
    402                 if (!WriteFile((HANDLE)File, (char*)pvBuf + cbWritten, cbToWrite - cbWritten, &cbWrittenPart, NULL))
     406                if (!WriteFile((HANDLE)File, (char*)pvBuf + cbWritten, cbToWriteAdj - cbWritten, &cbWrittenPart, NULL))
    403407                {
    404408                    int rc = RTErrConvertFromWin32(GetLastError());
    405409                    if (   rc == VERR_DISK_FULL
    406                         && IsBeyondLimit(File, cbToWrite - cbWritten, FILE_CURRENT)
     410                        && IsBeyondLimit(File, cbToWriteAdj - cbWritten, FILE_CURRENT)
    407411                       )
    408412                        rc = VERR_FILE_TOO_BIG;
     
    418422    int rc = RTErrConvertFromWin32(GetLastError());
    419423    if (   rc == VERR_DISK_FULL
    420         && IsBeyondLimit(File, cbToWrite - cbWritten, FILE_CURRENT)
    421        )
     424        && IsBeyondLimit(File, cbToWriteAdj - cbWritten, FILE_CURRENT))
    422425        rc = VERR_FILE_TOO_BIG;
    423426    return rc;
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