Index: /trunk/src/VBox/Devices/Storage/DevAHCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 63908)
+++ /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 63909)
@@ -4503,11 +4503,12 @@
                             break;
                         default:
-                            goto error_cmd;
+                            atapiCmdErrorSimple(pAhciPort, pAhciReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
+                            break;
                     }
                     break;
                 case SCSI_PAGECONTROL_CHANGEABLE:
-                    goto error_cmd;
                 case SCSI_PAGECONTROL_DEFAULT:
-                    goto error_cmd;
+                    atapiCmdErrorSimple(pAhciPort, pAhciReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
+                    break;
                 default:
                 case SCSI_PAGECONTROL_SAVED:
@@ -4760,5 +4761,4 @@
                     break;
                 default:
-                  error_cmd:
                     atapiCmdErrorSimple(pAhciPort, pAhciReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
                     break;
@@ -4840,4 +4840,5 @@
     uint32_t cbTransfer = 0;
     AHCITXDIR enmTxDir = AHCITXDIR_NONE;
+    bool fSendCmd = false;
 
     pbPacket = pAhciReq->aATAPICmd;
@@ -4845,7 +4846,9 @@
     {
         case SCSI_BLANK:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_CLOSE_TRACK_SESSION:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_ERASE_10:
             iATAPILBA = ataBE2H_U32(pbPacket + 2);
@@ -4853,13 +4856,16 @@
             Log2(("ATAPI PT: lba %d\n", iATAPILBA));
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_FORMAT_UNIT:
             cbTransfer = pAhciReq->cmdFis[AHCI_CMDFIS_CYLL] | (pAhciReq->cmdFis[AHCI_CMDFIS_CYLH] << 8); /* use ATAPI transfer length */
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_GET_CONFIGURATION:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_GET_EVENT_STATUS_NOTIFICATION:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
@@ -4871,38 +4877,50 @@
             }
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_GET_PERFORMANCE:
             cbTransfer = pAhciReq->cmdFis[AHCI_CMDFIS_CYLL] | (pAhciReq->cmdFis[AHCI_CMDFIS_CYLH] << 8); /* use ATAPI transfer length */
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_INQUIRY:
             cbTransfer = ataBE2H_U16(pbPacket + 3);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_LOAD_UNLOAD_MEDIUM:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_MECHANISM_STATUS:
             cbTransfer = ataBE2H_U16(pbPacket + 8);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_MODE_SELECT_10:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_MODE_SENSE_10:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_PAUSE_RESUME:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_PLAY_AUDIO_10:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_PLAY_AUDIO_12:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_PLAY_AUDIO_MSF:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
             /** @todo do not forget to unlock when a VM is shut down */
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_10:
             iATAPILBA = ataBE2H_U32(pbPacket + 2);
@@ -4912,5 +4930,6 @@
             cbTransfer = cSectors * pAhciReq->cbATAPISector;
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_12:
             iATAPILBA = ataBE2H_U32(pbPacket + 2);
@@ -4920,17 +4939,21 @@
             cbTransfer = cSectors * pAhciReq->cbATAPISector;
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_BUFFER:
             cbTransfer = ataBE2H_U24(pbPacket + 6);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_BUFFER_CAPACITY:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_CAPACITY:
             cbTransfer = 8;
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_CD:
         case SCSI_READ_CD_MSF:
@@ -4984,36 +5007,45 @@
             }
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         }
         case SCSI_READ_DISC_INFORMATION:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_DVD_STRUCTURE:
             cbTransfer = ataBE2H_U16(pbPacket + 8);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_FORMAT_CAPACITIES:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_SUBCHANNEL:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_TOC_PMA_ATIP:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_READ_TRACK_INFORMATION:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_REPAIR_TRACK:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_REPORT_KEY:
             cbTransfer = ataBE2H_U16(pbPacket + 8);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_REQUEST_SENSE:
             cbTransfer = pbPacket[4];
@@ -5026,49 +5058,66 @@
             }
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_RESERVE_TRACK:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SCAN:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SEEK_10:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SEND_CUE_SHEET:
             cbTransfer = ataBE2H_U24(pbPacket + 6);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SEND_DVD_STRUCTURE:
             cbTransfer = ataBE2H_U16(pbPacket + 8);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SEND_EVENT:
             cbTransfer = ataBE2H_U16(pbPacket + 8);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SEND_KEY:
             cbTransfer = ataBE2H_U16(pbPacket + 8);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SEND_OPC_INFORMATION:
             cbTransfer = ataBE2H_U16(pbPacket + 7);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SET_CD_SPEED:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SET_READ_AHEAD:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SET_STREAMING:
             cbTransfer = ataBE2H_U16(pbPacket + 9);
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_START_STOP_UNIT:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_STOP_PLAY_SCAN:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_SYNCHRONIZE_CACHE:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_TEST_UNIT_READY:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_VERIFY_10:
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_WRITE_10:
         case SCSI_WRITE_AND_VERIFY_10:
@@ -5082,5 +5131,6 @@
             cbTransfer = cSectors * pAhciReq->cbATAPISector;
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_WRITE_12:
             iATAPILBA = ataBE2H_U32(pbPacket + 2);
@@ -5093,5 +5143,6 @@
             cbTransfer = cSectors * pAhciReq->cbATAPISector;
             enmTxDir = AHCITXDIR_WRITE;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_WRITE_BUFFER:
             switch (pbPacket[1] & 0x1f)
@@ -5109,5 +5160,6 @@
                     cbTransfer = ataBE2H_U16(pbPacket + 6);
                     enmTxDir = AHCITXDIR_WRITE;
-                    goto sendcmd;
+                    fSendCmd = true;
+                    break;
             }
             break;
@@ -5115,5 +5167,6 @@
             cbTransfer = ataBE2H_U32(pbPacket + 6);
             enmTxDir = AHCITXDIR_READ;
-            goto sendcmd;
+            fSendCmd = true;
+            break;
         case SCSI_REZERO_UNIT:
             /* Obsolete command used by cdrecord. What else would one expect?
@@ -5128,12 +5181,15 @@
             atapiCmdErrorSimple(pAhciPort, pAhciReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
             break;
-        sendcmd:
-            /* Send a command to the drive, passing data in/out as required. */
-            Log2(("ATAPI PT: max size %d\n", cbTransfer));
-            if (cbTransfer == 0)
-                enmTxDir = AHCITXDIR_NONE;
-            pAhciReq->enmTxDir = enmTxDir;
-            pAhciReq->cbTransfer = cbTransfer;
-            atapiDoTransfer(pAhciPort, pAhciReq, cbTransfer, ATAFN_SS_ATAPI_PASSTHROUGH);
+    }
+
+    if (fSendCmd)
+    {
+        /* Send a command to the drive, passing data in/out as required. */
+        Log2(("ATAPI PT: max size %d\n", cbTransfer));
+        if (cbTransfer == 0)
+            enmTxDir = AHCITXDIR_NONE;
+        pAhciReq->enmTxDir = enmTxDir;
+        pAhciReq->cbTransfer = cbTransfer;
+        atapiDoTransfer(pAhciPort, pAhciReq, cbTransfer, ATAFN_SS_ATAPI_PASSTHROUGH);
     }
 
