VirtualBox

Changeset 83575 in vbox for trunk/src


Ignore:
Timestamp:
Apr 5, 2020 10:40:07 PM (5 years ago)
Author:
vboxsync
Message:

Virtio_1_0.cpp: Ditto uint64_t casting cleaning up in virtioCoreR3QueuePut. bugref:9440

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r83499 r83575  
    918918        {
    919919            PVIRTIOSGSEG paSeg = &pSgPhysReturn->paSegs[pSgPhysReturn->idxSeg];
    920             uint64_t dstSgStart = (uint64_t)paSeg->gcPhys;
    921             uint64_t dstSgLen   = (uint64_t)paSeg->cbSeg;
    922             uint64_t dstSgCur   = (uint64_t)pSgPhysReturn->gcPhysCur;
    923             cbCopy = RT_MIN((uint64_t)pSgVirtReturn->cbSegLeft, dstSgLen - (dstSgCur - dstSgStart));
     920            /** @todo r=bird: Shouldn't this be: RT_MIN(pSgVirtReturn->cbSegLeft, pSgPhysReturn->cbSegLeft); */
     921            cbCopy = RT_MIN(pSgVirtReturn->cbSegLeft, paSeg->cbSeg - (size_t)(pSgPhysReturn->gcPhysCur - paSeg->gcPhys));
     922            Assert(cbCopy > 0); /** @todo r=bird: There is no check that there is sufficient space in the output
     923                                 * buffer (pSgPhysReturn), so we might loop here forever if the caller is careless,
     924                                 * right?  I'm pretty sure virtioScsiR3SendEvent could do more checks. */
    924925            PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)pSgPhysReturn->gcPhysCur, pSgVirtReturn->pvSegCur, cbCopy);
    925926            RTSgBufAdvance(pSgVirtReturn, cbCopy);
     
    946947    if (pSgVirtReturn)
    947948        Log6Func((".... Copied %zu bytes in %d segs to %u byte buffer, residual=%zu\n",
    948               cbTotal - cbRemain, pSgVirtReturn->cSegs, pDescChain->cbPhysReturn, pDescChain->cbPhysReturn - cbTotal));
     949                  cbTotal - cbRemain, pSgVirtReturn->cSegs, pDescChain->cbPhysReturn, pDescChain->cbPhysReturn - cbTotal));
    949950
    950951    Log6Func(("Write ahead used_idx=%u, %s used_idx=%u\n",
     
    953954    if (pDescChain->pSgPhysSend)
    954955    {
    955         RTMemFree((void *)pDescChain->pSgPhysSend->paSegs);
     956        RTMemFree(pDescChain->pSgPhysSend->paSegs);
    956957        RTMemFree(pDescChain->pSgPhysSend);
    957958    }
    958959    if (pDescChain->pSgPhysReturn)
    959960    {
    960         RTMemFree((void *)pSgPhysReturn->paSegs);
     961        RTMemFree(pSgPhysReturn->paSegs);
    961962        RTMemFree(pSgPhysReturn);
    962963    }
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