Index: /trunk/src/VBox/Devices/Storage/DevAHCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 62962)
+++ /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 62963)
@@ -313,5 +313,5 @@
     uint8_t                    aATAPICmd[ATAPI_PACKET_SIZE];
     /** Size of one sector for the ATAPI transfer. */
-    size_t                     cbATAPISector;
+    uint32_t                   cbATAPISector;
     /** Physical address of the command header. - GC */
     RTGCPHYS                   GCPhysCmdHdrAddr;
@@ -958,8 +958,6 @@
 static int  ahciPostFisIntoMemory(PAHCIPort pAhciPort, unsigned uFisType, uint8_t *cmdFis);
 static void ahciPostFirstD2HFisIntoMemory(PAHCIPort pAhciPort);
-static size_t ahciCopyToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq,
-                              void *pvBuf, size_t cbBuf);
-static size_t ahciCopyFromPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq,
-                                void *pvBuf, size_t cbBuf);
+static uint32_t ahciCopyToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, const void *pvBuf, size_t cbBuf);
+static size_t ahciCopyFromPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, void *pvBuf, size_t cbBuf);
 static bool ahciCancelActiveTasks(PAHCIPort pAhciPort, PAHCIREQ pAhciReqExcept);
 static void ahciReqMemFree(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, bool fForceFree);
@@ -1070,4 +1068,5 @@
 
 #ifdef IN_RING3
+
 /*
  * Assert irq when an CCC timeout occurs
@@ -1075,4 +1074,5 @@
 static DECLCALLBACK(void) ahciCccTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
 {
+    RT_NOREF(pDevIns, pTimer);
     PAHCI pAhci = (PAHCI)pvUser;
 
@@ -1091,5 +1091,5 @@
     /* Cancel all tasks first. */
     bool fAllTasksCanceled = ahciCancelActiveTasks(pAhciPort, NULL);
-    Assert(fAllTasksCanceled);
+    Assert(fAllTasksCanceled); NOREF(fAllTasksCanceled);
 
     /* Signature for SATA device. */
@@ -1137,5 +1137,6 @@
     ASMAtomicXchgBool(&pAhciPort->fPortReset, false);
 }
-#endif
+
+#endif /* IN_RING3 */
 
 /**
@@ -1280,5 +1281,5 @@
 
         pAhciPort->regSSTS = 0;
-        pAhciPort->regSIG  = ~0;
+        pAhciPort->regSIG  = UINT32_MAX;
         pAhciPort->regTFD  = 0x7f;
         pAhciPort->fFirstD2HFisSend = false;
@@ -2077,5 +2078,5 @@
 
     pAhciPort->regTFD  = (1 << 8) | ATA_STAT_SEEK | ATA_STAT_WRERR;
-    pAhciPort->regSIG  = ~0;
+    pAhciPort->regSIG  = UINT32_MAX;
     pAhciPort->regSSTS = 0;
     pAhciPort->regSCTL = 0;
@@ -2548,7 +2549,8 @@
 #ifdef IN_RING3
 
-static DECLCALLBACK(int) ahciR3MMIOMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb,
-                                       PCIADDRESSSPACE enmType)
-{
+static DECLCALLBACK(int)
+ahciR3MMIOMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
+{
+    RT_NOREF(iRegion, enmType);
     PAHCI pThis = PCIDEV_2_PAHCI(pPciDev);
     PPDMDEVINS pDevIns = pPciDev->pDevIns;
@@ -2590,6 +2592,8 @@
  * Map the legacy I/O port ranges to make Solaris work with the controller.
  */
-static DECLCALLBACK(int) ahciR3LegacyFakeIORangeMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
-{
+static DECLCALLBACK(int)
+ahciR3LegacyFakeIORangeMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
+{
+    RT_NOREF(iRegion, enmType);
     PAHCI pThis = PCIDEV_2_PAHCI(pPciDev);
     PPDMDEVINS pDevIns = pPciDev->pDevIns;
@@ -2628,6 +2632,8 @@
  * Map the BMDMA I/O port range (used for the Index/Data pair register access)
  */
-static DECLCALLBACK(int) ahciR3IdxDataIORangeMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
-{
+static DECLCALLBACK(int)
+ahciR3IdxDataIORangeMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
+{
+    RT_NOREF(iRegion, enmType);
     PAHCI pThis = PCIDEV_2_PAHCI(pPciDev);
     PPDMDEVINS pDevIns = pPciDev->pDevIns;
@@ -3083,8 +3089,5 @@
 static int ahciIdentifySS(PAHCIPort pAhciPort, void *pvBuf)
 {
-    uint16_t *p;
-    int rc = VINF_SUCCESS;
-
-    p = (uint16_t *)pvBuf;
+    uint16_t *p = (uint16_t *)pvBuf;
     memset(p, 0, 512);
     p[0] = RT_H2LE_U16(0x0040);
@@ -3301,6 +3304,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData =  ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&p[0],
-                                RT_MIN(cbData, sizeof(p)));
+    *pcbData =  ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&p[0], RT_MIN(cbData, sizeof(p)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3316,6 +3318,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3344,6 +3345,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3375,6 +3375,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3382,5 +3381,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureListProfiles(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureListProfiles(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 3*4)
@@ -3400,5 +3399,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureCore(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureCore(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 12)
@@ -3415,5 +3414,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureMorphing(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureMorphing(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 8)
@@ -3429,5 +3428,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureRemovableMedium(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureRemovableMedium(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 8)
@@ -3444,5 +3443,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureRandomReadable(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureRandomReadable(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 12)
@@ -3460,5 +3459,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureCDRead(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureCDRead(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 8)
@@ -3474,5 +3473,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeaturePowerManagement(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeaturePowerManagement(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 4)
@@ -3486,5 +3485,5 @@
 }
 
-static size_t atapiGetConfigurationFillFeatureTimeout(PAHCIPort pAhciPort, uint8_t *pbBuf, size_t cbBuf)
+static size_t atapiGetConfigurationFillFeatureTimeout(uint8_t *pbBuf, size_t cbBuf)
 {
     if (cbBuf < 8)
@@ -3521,42 +3520,41 @@
     pbBuf    += 8;
 
-    cbCopied = atapiGetConfigurationFillFeatureListProfiles(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureListProfiles(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeatureCore(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureCore(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeatureMorphing(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureMorphing(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeatureRemovableMedium(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureRemovableMedium(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeatureRandomReadable(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureRandomReadable(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeatureCDRead(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureCDRead(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeaturePowerManagement(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeaturePowerManagement(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
-    cbCopied = atapiGetConfigurationFillFeatureTimeout(pAhciPort, pbBuf, cbBuf);
+    cbCopied = atapiGetConfigurationFillFeatureTimeout(pbBuf, cbBuf);
     cbBuf -= cbCopied;
     pbBuf += cbCopied;
 
     /* Set data length now. */
-    ataH2BE_U32(&aBuf[0], sizeof(aBuf) - cbBuf);
+    ataH2BE_U32(&aBuf[0], (uint32_t)(sizeof(aBuf) - cbBuf));
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3634,6 +3632,5 @@
     } while (!ASMAtomicCmpXchgU32(&pAhciPort->MediaEventStatus, NewStatus, OldStatus));
 
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&abBuf[0],
-                               RT_MIN(cbData, sizeof(abBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&abBuf[0], RT_MIN(cbData, sizeof(abBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3659,6 +3656,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3689,6 +3685,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3740,6 +3735,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3772,6 +3766,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3835,6 +3828,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, cbSize));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, cbSize));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3869,6 +3861,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, sizeof(aBuf)));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, sizeof(aBuf)));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3958,6 +3949,5 @@
 
     /* Copy the buffer in to the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, cbSize));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, cbSize));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -3975,4 +3965,5 @@
 static int atapiPassthroughSS(PAHCIREQ pAhciReq, PAHCIPort pAhciPort, size_t cbData, size_t *pcbData)
 {
+    RT_NOREF(cbData);
     int rc = VINF_SUCCESS;
     uint8_t abATAPISense[ATAPI_SENSE_SIZE];
@@ -4012,5 +4003,5 @@
          * imbalance of powers. */
         uint8_t aATAPICmd[ATAPI_PACKET_SIZE];
-        uint32_t iATAPILBA, cSectors, cReqSectors, cbCurrTX;
+        uint32_t iATAPILBA, cSectors;
         uint8_t *pbBuf = (uint8_t *)pvBuf;
 
@@ -4045,5 +4036,5 @@
         }
         memcpy(aATAPICmd, pAhciReq->aATAPICmd, ATAPI_PACKET_SIZE);
-        cReqSectors = 0;
+        uint32_t cReqSectors = 0;
         for (uint32_t i = cSectors; i > 0; i -= cReqSectors)
         {
@@ -4052,5 +4043,5 @@
             else
                 cReqSectors = i;
-            cbCurrTX = pAhciReq->cbATAPISector * cReqSectors;
+            uint32_t cbCurrTX = pAhciReq->cbATAPISector * cReqSectors;
             switch (pAhciReq->aATAPICmd[0])
             {
@@ -4179,6 +4170,5 @@
 
                 /* Reply with the same amount of data as the real drive. */
-                *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, pvBuf,
-                                           cbTransfer);
+                *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, pvBuf, cbTransfer);
             }
             else
@@ -4371,6 +4361,5 @@
 
     /* Copy the buffer into the scatter gather list. */
-    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0],
-                               RT_MIN(cbData, max_len));
+    *pcbData = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, (void *)&aBuf[0], RT_MIN(cbData, max_len));
 
     atapiCmdOK(pAhciPort, pAhciReq);
@@ -4381,11 +4370,9 @@
 {
     size_t cbTransfered = 0;
-    int rcSourceSink;
-
-    rcSourceSink = g_apfnAtapiFuncs[iSourceSink](pAhciReq, pAhciPort, cbMax,
-                                                 &cbTransfered);
-
-    pAhciReq->cmdHdr.u32PRDBC = cbTransfered;
-    pAhciReq->cbTransfer = cbTransfered;
+    int rcSourceSink = g_apfnAtapiFuncs[iSourceSink](pAhciReq, pAhciPort, cbMax, &cbTransfered);
+
+    pAhciReq->cmdHdr.u32PRDBC = (uint32_t)cbTransfered;
+    pAhciReq->cbTransfer      = (uint32_t)cbTransfered;
+    Assert(pAhciReq->cbTransfer == cbTransfered);
 
     LogFlow(("cbTransfered=%d\n", cbTransfered));
@@ -4439,4 +4426,5 @@
 static int atapiReadSectors(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, uint32_t iATAPILBA, uint32_t cSectors, uint32_t cbSector)
 {
+    RT_NOREF(pAhciPort);
     Log(("%s: %d sectors at LBA %d\n", __FUNCTION__, cSectors, iATAPILBA));
 
@@ -5557,12 +5545,11 @@
  * @param   cbBuf          The size of the buffer.
  */
-static size_t ahciCopyToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq,
-                              void *pvBuf, size_t cbBuf)
-{
-    uint8_t *pbBuf = (uint8_t *)pvBuf;
+static uint32_t ahciCopyToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, void const *pvBuf, size_t cbBuf)
+{
+    uint8_t const *pbBuf = (uint8_t const *)pvBuf;
     SGLEntry aPrdtlEntries[32];
     RTGCPHYS GCPhysPrdtl = pAhciReq->GCPhysPrdtl;
     unsigned cPrdtlEntries = pAhciReq->cPrdtlEntries;
-    size_t cbCopied = 0;
+    uint32_t cbCopied = 0;
 
     AssertMsgReturn(cPrdtlEntries > 0, ("Copying 0 bytes is not possible\n"), 0);
@@ -5581,5 +5568,5 @@
             uint32_t cbThisCopy = (aPrdtlEntries[i].u32DescInf & SGLENTRY_DESCINF_DBC) + 1;
 
-            cbThisCopy = RT_MIN(cbThisCopy, cbBuf);
+            cbThisCopy = (uint32_t)RT_MIN(cbThisCopy, cbBuf);
 
             /* Copy into SG entry. */
@@ -5634,5 +5621,5 @@
             uint32_t cbThisCopy = (aPrdtlEntries[i].u32DescInf & SGLENTRY_DESCINF_DBC) + 1;
 
-            cbThisCopy = RT_MIN(cbThisCopy, cbBuf);
+            cbThisCopy = (uint32_t)RT_MIN(cbThisCopy, cbBuf);
 
             /* Copy into buffer. */
@@ -5714,7 +5701,5 @@
         }
         else
-            ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq,
-                            pAhciReq->u.Io.DataSeg.pvSeg,
-                            pAhciReq->u.Io.DataSeg.cbSeg);
+            ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, pAhciReq->u.Io.DataSeg.pvSeg, pAhciReq->u.Io.DataSeg.cbSeg);
     }
 
@@ -6299,5 +6284,4 @@
     AHCITXDIR enmTxDir = AHCITXDIR_NONE;
     bool fLBA48 = false;
-    CmdHdr   *pCmdHdr = &pAhciReq->cmdHdr;
 
     AssertMsg(pCmdFis[AHCI_CMDFIS_TYPE] == AHCI_CMDFIS_TYPE_H2D, ("FIS is not a host to device Fis!!\n"));
@@ -6312,5 +6296,4 @@
             {
                 uint16_t u16Temp[256];
-                size_t cbCopied;
 
                 /* Fill the buffer. */
@@ -6318,6 +6301,5 @@
 
                 /* Copy the buffer. */
-                cbCopied = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq,
-                                           &u16Temp[0], sizeof(u16Temp));
+                uint32_t cbCopied = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, &u16Temp[0], sizeof(u16Temp));
 
                 pAhciReq->fFlags |= AHCI_REQ_PIO_DATA;
@@ -6486,5 +6468,4 @@
             unsigned offLogRead = ((pCmdFis[AHCI_CMDFIS_CYLLEXP] << 8) | pCmdFis[AHCI_CMDFIS_CYLL]) * 512;
             unsigned iPage = pCmdFis[AHCI_CMDFIS_SECTN];
-            size_t cbCopied;
 
             LogFlow(("Trying to read %zu bytes starting at offset %u from page %u\n", cbLogRead, offLogRead, iPage));
@@ -6540,5 +6521,5 @@
                          */
                         bool fAbortedAll = ahciCancelActiveTasks(pAhciPort, pAhciReq);
-                        Assert(fAbortedAll);
+                        Assert(fAbortedAll); NOREF(fAbortedAll);
                         ahciSendSDBFis(pAhciPort, 0xffffffff, true);
 
@@ -6548,6 +6529,5 @@
 
                 /* Copy the buffer. */
-                cbCopied = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq,
-                                           &aBuf[offLogRead], cbLogRead);
+                uint32_t cbCopied = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, &aBuf[offLogRead], cbLogRead);
 
                 pAhciReq->fFlags |= AHCI_REQ_PIO_DATA;
@@ -6881,12 +6861,8 @@
 static DECLCALLBACK(int) ahciAsyncIOLoop(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
 {
+    RT_NOREF(pDevIns);
     PAHCIPort pAhciPort = (PAHCIPort)pThread->pvUser;
     PAHCI     pAhci     = pAhciPort->CTX_SUFF(pAhci);
-    int rc = VINF_SUCCESS;
-    uint64_t u64StartTime = 0;
-    uint64_t u64StopTime  = 0;
-    uint32_t uIORequestsProcessed = 0;
-    uint32_t uIOsPerSec = 0;
-    uint32_t fTasksToProcess = 0;
+    int       rc        = VINF_SUCCESS;
 
     ahciLog(("%s: Port %d entering async IO loop.\n", __FUNCTION__, pAhciPort->iLUN));
@@ -7070,4 +7046,5 @@
 static DECLCALLBACK(void) ahciR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
 {
+    RT_NOREF(pszArgs);
     PAHCI pThis = PDMINS_2_DATA(pDevIns, PAHCI);
 
@@ -7171,4 +7148,5 @@
 static DECLCALLBACK(int) ahciR3SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
 {
+    RT_NOREF(pDevIns, pSSM);
     Assert(ahciR3AllAsyncIOIsFinished(pDevIns));
     return VINF_SUCCESS;
@@ -7180,4 +7158,5 @@
 static DECLCALLBACK(int) ahciR3LoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
 {
+    RT_NOREF(pDevIns, pSSM);
     Assert(ahciR3AllAsyncIOIsFinished(pDevIns));
     return VINF_SUCCESS;
@@ -7189,4 +7168,5 @@
 static DECLCALLBACK(int) ahciR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
 {
+    RT_NOREF(uPass);
     PAHCI pThis = PDMINS_2_DATA(pDevIns, PAHCI);
 
@@ -7203,5 +7183,5 @@
 
     static const char *s_apszIdeEmuPortNames[4] = { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
-    for (size_t i = 0; i < RT_ELEMENTS(s_apszIdeEmuPortNames); i++)
+    for (uint32_t i = 0; i < RT_ELEMENTS(s_apszIdeEmuPortNames); i++)
     {
         uint32_t iPort;
@@ -7439,5 +7419,5 @@
 
         static const char *s_apszIdeEmuPortNames[4] = { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
-        for (size_t i = 0; i < RT_ELEMENTS(s_apszIdeEmuPortNames); i++)
+        for (uint32_t i = 0; i < RT_ELEMENTS(s_apszIdeEmuPortNames); i++)
         {
             uint32_t iPort;
@@ -7898,6 +7878,4 @@
 static int ahciR3VpdInit(PPDMDEVINS pDevIns, PAHCIPort pAhciPort, const char *pszName)
 {
-    int rc = VINF_SUCCESS;
-    PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI);
 
     /* Generate a default serial number. */
@@ -7905,4 +7883,5 @@
     RTUUID Uuid;
 
+    int rc = VINF_SUCCESS;
     if (pAhciPort->pDrvMedia)
         rc = pAhciPort->pDrvMedia->pfnGetUuid(pAhciPort->pDrvMedia, &Uuid);
@@ -8209,4 +8188,5 @@
 static int ahciR3ResetCommon(PPDMDEVINS pDevIns, bool fConstructor)
 {
+    RT_NOREF(fConstructor);
     PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI);
 
