VirtualBox

儲存庫 vbox 的更動 18443


忽略:
時間撮記:
2009-3-28 上午03:15:18 (16 年 以前)
作者:
vboxsync
訊息:

DrvNamedPipe: Fixed (?) undefined variable in odd error case in drvNamedPipeWrite on windows. Some size_t warnings and hungarian spelling mistakes.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Serial/DrvNamedPipe.cpp

    r11284 r18443  
    100100
    101101/** @copydoc PDMISTREAM::pfnRead */
    102 static DECLCALLBACK(int) drvNamedPipeRead(PPDMISTREAM pInterface, void *pvBuf, size_t *cbRead)
     102static DECLCALLBACK(int) drvNamedPipeRead(PPDMISTREAM pInterface, void *pvBuf, size_t *pcbRead)
    103103{
    104104    int rc = VINF_SUCCESS;
    105105    PDRVNAMEDPIPE pThis = PDMISTREAM_2_DRVNAMEDPIPE(pInterface);
    106     LogFlow(("%s: pvBuf=%p cbRead=%#x (%s)\n", __FUNCTION__, pvBuf, cbRead, pThis->pszLocation));
     106    LogFlow(("%s: pvBuf=%p *pcbRead=%#x (%s)\n", __FUNCTION__, pvBuf, *pcbRead, pThis->pszLocation));
    107107
    108108    Assert(pvBuf);
     
    113113        pThis->OverlappedRead.Offset     = 0;
    114114        pThis->OverlappedRead.OffsetHigh = 0;
    115         if (!ReadFile(pThis->NamedPipe, pvBuf, *cbRead, &cbReallyRead, &pThis->OverlappedRead))
     115        if (!ReadFile(pThis->NamedPipe, pvBuf, (DWORD)*pcbRead, &cbReallyRead, &pThis->OverlappedRead))
    116116        {
    117117            DWORD uError = GetLastError();
     
    164164            cbReallyRead = 0;
    165165        }
    166         *cbRead = (size_t)cbReallyRead;
     166        *pcbRead = (size_t)cbReallyRead;
    167167    }
    168168#else /* !RT_OS_WINDOWS */
     
    170170    {
    171171        ssize_t cbReallyRead;
    172         cbReallyRead = recv(pThis->LocalSocket, pvBuf, *cbRead, 0);
     172        cbReallyRead = recv(pThis->LocalSocket, pvBuf, *pcbRead, 0);
    173173        if (cbReallyRead == 0)
    174174        {
     
    182182            rc = RTErrConvertFromErrno(errno);
    183183        }
    184         *cbRead = cbReallyRead;
     184        *pcbRead = cbReallyRead;
    185185    }
    186186#endif /* !RT_OS_WINDOWS */
     
    188188    {
    189189        RTThreadSleep(100);
    190         *cbRead = 0;
    191     }
    192 
    193     LogFlow(("%s: cbRead=%d returns %Rrc\n", __FUNCTION__, *cbRead, rc));
     190        *pcbRead = 0;
     191    }
     192
     193    LogFlow(("%s: *pcbRead=%zu returns %Rrc\n", __FUNCTION__, *pcbRead, rc));
    194194    return rc;
    195195}
     
    197197
    198198/** @copydoc PDMISTREAM::pfnWrite */
    199 static DECLCALLBACK(int) drvNamedPipeWrite(PPDMISTREAM pInterface, const void *pvBuf, size_t *cbWrite)
     199static DECLCALLBACK(int) drvNamedPipeWrite(PPDMISTREAM pInterface, const void *pvBuf, size_t *pcbWrite)
    200200{
    201201    int rc = VINF_SUCCESS;
    202202    PDRVNAMEDPIPE pThis = PDMISTREAM_2_DRVNAMEDPIPE(pInterface);
    203     LogFlow(("%s: pvBuf=%p cbWrite=%#x (%s)\n", __FUNCTION__, pvBuf, cbWrite, pThis->pszLocation));
     203    LogFlow(("%s: pvBuf=%p *pcbWrite=%#x (%s)\n", __FUNCTION__, pvBuf, *pcbWrite, pThis->pszLocation));
    204204
    205205    Assert(pvBuf);
     
    207207    if (pThis->NamedPipe != INVALID_HANDLE_VALUE)
    208208    {
    209         unsigned cbWritten;
     209        DWORD cbWritten = (DWORD)*pcbWrite;
    210210        pThis->OverlappedWrite.Offset     = 0;
    211211        pThis->OverlappedWrite.OffsetHigh = 0;
    212         if (!WriteFile(pThis->NamedPipe, pvBuf, *cbWrite, NULL, &pThis->OverlappedWrite))
     212        if (!WriteFile(pThis->NamedPipe, pvBuf, cbWritten, NULL, &pThis->OverlappedWrite))
    213213        {
    214214            DWORD uError = GetLastError();
     
    217217                || uError == ERROR_PIPE_NOT_CONNECTED)
    218218            {
    219                 /* No connection yet/anymore; just discard the write. */
    220                 cbWritten = *cbWrite;
    221             }
    222             else
    223             if (uError != ERROR_IO_PENDING)
     219                /* No connection yet/anymore; just discard the write (pretening everything was written). */;
     220            }
     221            else if (uError != ERROR_IO_PENDING)
    224222            {
    225223                rc = RTErrConvertFromWin32(uError);
    226224                Log(("drvNamedPipeWrite: WriteFile returned %d (%Rrc)\n", uError, rc));
     225                cbWritten = 0;
    227226            }
    228227            else
    229228            {
    230229                /* Wait for the write to complete. */
    231                 if (GetOverlappedResult(pThis->NamedPipe, &pThis->OverlappedWrite, (DWORD *)&cbWritten, TRUE) == FALSE)
    232                     uError = GetLastError();
    233             }
    234         }
    235         else
    236             cbWritten = *cbWrite;
     230                if (GetOverlappedResult(pThis->NamedPipe, &pThis->OverlappedWrite, &cbWritten, TRUE /*bWait*/) == FALSE)
     231                    rc = RTErrConvertFromWin32(uError = GetLastError());
     232            }
     233        }
    237234
    238235        if (RT_FAILURE(rc))
     
    253250            cbWritten = 0;
    254251        }
    255         *cbWrite = cbWritten;
     252        *pcbWrite = cbWritten;
    256253    }
    257254#else /* !RT_OS_WINDOWS */
     
    259256    {
    260257        ssize_t cbWritten;
    261         cbWritten = send(pThis->LocalSocket, pvBuf, *cbWrite, 0);
     258        cbWritten = send(pThis->LocalSocket, pvBuf, *pcbWrite, 0);
    262259        if (cbWritten == 0)
    263260        {
     
    271268            rc = RTErrConvertFromErrno(errno);
    272269        }
    273         *cbWrite = cbWritten;
     270        *pcbWrite = cbWritten;
    274271    }
    275272#endif /* !RT_OS_WINDOWS */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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