VirtualBox

Changeset 104580 in vbox


Ignore:
Timestamp:
May 13, 2024 8:48:29 AM (7 months ago)
Author:
vboxsync
Message:

Devies/Storage/VSCSI: Call scsiBE2H_U16() jsut once outside of RT_MIN() to avoid calling it twice (harmless, scsiBE2H_U16() has no side effects but a compiler might generate non-optimal code), missing call to vscsiDeviceReqComplete(), bugref:3409

Location:
trunk/src/VBox/Devices/Storage/VSCSI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIDevice.cpp

    r104221 r104580  
    8383            if (!vscsiDeviceLunIsPresent(pVScsiDevice, pVScsiReq->iLun))
    8484            {
    85                 size_t cbData;
    8685                SCSIINQUIRYDATA ScsiInquiryReply;
    8786
     87                uint16_t cbDataReq = scsiBE2H_U16(&pVScsiReq->pbCDB[3]);
    8888                vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I);
    89                 vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), scsiBE2H_U16(&pVScsiReq->pbCDB[3])));
     89                vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), cbDataReq));
    9090                memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply));
    9191                ScsiInquiryReply.cbAdditional = 31;
    9292                ScsiInquiryReply.u5PeripheralDeviceType = SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_UNKNOWN;
    9393                ScsiInquiryReply.u3PeripheralQualifier = SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_NOT_SUPPORTED;
    94                 cbData = RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, (uint8_t *)&ScsiInquiryReply, sizeof(SCSIINQUIRYDATA));
     94                RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, (uint8_t *)&ScsiInquiryReply, sizeof(SCSIINQUIRYDATA));
    9595                *prcReq = vscsiReqSenseOkSet(&pVScsiDevice->VScsiSense, pVScsiReq);
    9696            }
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunMmc.cpp

    r104222 r104580  
    11041104                SCSIINQUIRYDATA ScsiInquiryReply;
    11051105
     1106                uint16_t cbDataReq = scsiBE2H_U16(&pVScsiReq->pbCDB[3]);
    11061107                vscsiReqSetXferDir(pVScsiReq, VSCSIXFERDIR_T2I);
    1107                 vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), scsiBE2H_U16(&pVScsiReq->pbCDB[3])));
     1108                vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), cbDataReq));
    11081109                memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply));
    11091110
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunSbc.cpp

    r104222 r104580  
    235235                    SCSIINQUIRYDATA ScsiInquiryReply;
    236236
    237                     vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), scsiBE2H_U16(&pVScsiReq->pbCDB[3])));
     237                    uint16_t cbDataReq = scsiBE2H_U16(&pVScsiReq->pbCDB[3]);
     238                    vscsiReqSetXferSize(pVScsiReq, RT_MIN(sizeof(SCSIINQUIRYDATA), cbDataReq));
    238239                    memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply));
    239240
     
    558559
    559560                                paRanges[i].offStart = scsiBE2H_U64(&abBlkDesc[0]) * 512;
    560                                 paRanges[i].cbRange = scsiBE2H_U32(&abBlkDesc[8]) * 512;
     561                                paRanges[i].cbRange = (size_t)scsiBE2H_U32(&abBlkDesc[8]) * 512;
    561562                            }
    562563
     
    613614                    || enmTxDir == VSCSIIOREQTXDIR_FLUSH)
    614615                && (pVScsiLun->fFeatures & VSCSI_LUN_FEATURE_READONLY))
     616            {
    615617                rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_DATA_PROTECT, SCSI_ASC_WRITE_PROTECTED, 0x00);
     618                vscsiDeviceReqComplete(pVScsiLun->pVScsiDevice, pVScsiReq, rcReq, false, VINF_SUCCESS);
     619            }
    616620            else
    617621            {
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