Index: trunk/src/VBox/Devices/Storage/DevATA.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 15854)
+++ trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 15855)
@@ -282,9 +282,9 @@
 
     /** The serial numnber to use for IDENTIFY DEVICE commands. */
-    char                                achSerialNumber[ATA_SERIAL_NUMBER_LENGTH+1];
+    char                                szSerialNumber[ATA_SERIAL_NUMBER_LENGTH+1];
     /** The firmware revision to use for IDENTIFY DEVICE commands. */
-    char                                achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH+1];
+    char                                szFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH+1];
     /** The model number to use for IDENTIFY DEVICE commands. */
-    char                                achModelNumber[ATA_MODEL_NUMBER_LENGTH+1];
+    char                                szModelNumber[ATA_MODEL_NUMBER_LENGTH+1];
 
 #if HC_ARCH_BITS == 64
@@ -1113,10 +1113,10 @@
     p[5] = RT_H2LE_U16(512);
     p[6] = RT_H2LE_U16(s->PCHSGeometry.cSectors);
-    ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
+    ataPadString((uint8_t *)(p + 10), s->szSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
     p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */
     p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */
     p[22] = RT_H2LE_U16(0); /* ECC bytes per sector */
-    ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
-    ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
+    ataPadString((uint8_t *)(p + 23), s->szFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
+    ataPadString((uint8_t *)(p + 27), s->szModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
 #if ATA_MAX_MULT_SECTORS > 1
     p[47] = RT_H2LE_U16(0x8000 | ATA_MAX_MULT_SECTORS);
@@ -1219,9 +1219,9 @@
     /* Removable CDROM, 50us response, 12 byte packets */
     p[0] = RT_H2LE_U16(2 << 14 | 5 << 8 | 1 << 7 | 2 << 5 | 0 << 0);
-    ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
+    ataPadString((uint8_t *)(p + 10), s->szSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
     p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */
     p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */
-    ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
-    ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
+    ataPadString((uint8_t *)(p + 23), s->szFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
+    ataPadString((uint8_t *)(p + 27), s->szModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
     p[49] = RT_H2LE_U16(1 << 11 | 1 << 9 | 1 << 8); /* DMA and LBA supported */
     p[50] = RT_H2LE_U16(1 << 14);  /* No drive specific standby timer minimum */
@@ -4303,5 +4303,5 @@
         {
             rc = RTSemEventWait(pCtl->SuspendIOSem, RT_INDEFINITE_WAIT);
-            /* Continue if we got a signal by RTThreadPoke(). 
+            /* Continue if we got a signal by RTThreadPoke().
              * We will get notified if there is a request to process.
              */
@@ -4320,5 +4320,5 @@
             rc = RTSemEventWait(pCtl->AsyncIOSem, RT_INDEFINITE_WAIT);
             LogBird(("ata: %x: waking up\n", pCtl->IOPortBase1));
-            /* Continue if we got a signal by RTThreadPoke(). 
+            /* Continue if we got a signal by RTThreadPoke().
              * We will get notified if there is a request to process.
              */
@@ -6352,5 +6352,7 @@
                         { "SecondaryMaster", "SecondarySlave" }
                     };
-                    char aSerial[ATA_SERIAL_NUMBER_LENGTH+1];
+
+                    /* Generate a default serial number. */
+                    char szSerial[ATA_SERIAL_NUMBER_LENGTH+1];
                     RTUUID Uuid;
                     if (pIf->pDrvBlock)
@@ -6362,50 +6364,44 @@
                     {
                         /* Generate a predictable serial for drives which don't have a UUID. */
-                        RTStrPrintf(aSerial, sizeof(aSerial), "VB%x-%04x%04x",
+                        RTStrPrintf(szSerial, sizeof(szSerial), "VB%x-%04x%04x",
                                     pIf->iLUN + pDevIns->iInstance * 32,
                                     pThis->aCts[i].IOPortBase1, pThis->aCts[i].IOPortBase2);
                     }
                     else
-                        RTStrPrintf(aSerial, sizeof(aSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]);
-                    strncpy(pIf->achSerialNumber, aSerial, sizeof(pIf->achSerialNumber));
-                    strncpy(pIf->achFirmwareRevision, "1.0", sizeof(pIf->achSerialNumber));
-                    if (pIf->fATAPI)
-                        strncpy(pIf->achModelNumber, "VBOX CD-ROM", sizeof(pIf->achModelNumber));
-                    else
-                        strncpy(pIf->achModelNumber, "VBOX HARDDISK", sizeof(pIf->achModelNumber));
-
-                    /* Check if the user provided some values to overwrite. */
+                        RTStrPrintf(szSerial, sizeof(szSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]);
+
+                    /* Get user config if present using defaults otherwise. */
                     PCFGMNODE pCfgNode = CFGMR3GetChild(pCfgHandle, s_apszCFGMKeys[i][j]);
-                    if (pCfgNode)
+                    rc = CFGMR3QueryStringDef(pCfgNode, "SerialNumber", pIf->szSerialNumber, sizeof(pIf->szSerialNumber),
+                                              szSerial);
+                    if (RT_FAILURE(rc))
                     {
-                        rc = CFGMR3QueryString(pCfgNode, "SerialNumber", pIf->achSerialNumber, sizeof(pIf->achSerialNumber));
                         if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
-                        {
                             return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
                                         N_("PIIX3 configuration error: \"SerialNumber\" is longer than 20 bytes"));
-                        }
-                        else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
-                            return PDMDEV_SET_ERROR(pDevIns, rc,
-                                        N_("PIIX3 configuration error: failed to read \"SerialNumber\" as string"));
-
-                        rc = CFGMR3QueryString(pCfgNode, "FirmwareRevision", pIf->achFirmwareRevision, sizeof(pIf->achFirmwareRevision));
+                        return PDMDEV_SET_ERROR(pDevIns, rc,
+                                  N_("PIIX3 configuration error: failed to read \"SerialNumber\" as string"));
+                    }
+
+                    rc = CFGMR3QueryStringDef(pCfgNode, "FirmwareRevision", pIf->szFirmwareRevision, sizeof(pIf->szFirmwareRevision),
+                                              "1.0");
+                    if (RT_FAILURE(rc))
+                    {
                         if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
-                        {
                             return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
                                         N_("PIIX3 configuration error: \"FirmwareRevision\" is longer than 8 bytes"));
-                        }
-                        else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
-                            return PDMDEV_SET_ERROR(pDevIns, rc,
-                                        N_("PIIX3 configuration error: failed to read \"FirmwareRevision\" as string"));
-
-                        rc = CFGMR3QueryString(pCfgNode, "ModelNumber", pIf->achModelNumber, sizeof(pIf->achModelNumber));
+                        return PDMDEV_SET_ERROR(pDevIns, rc,
+                                    N_("PIIX3 configuration error: failed to read \"FirmwareRevision\" as string"));
+                    }
+
+                    rc = CFGMR3QueryStringDef(pCfgNode, "ModelNumber", pIf->szModelNumber, sizeof(pIf->szModelNumber),
+                                              pIf->fATAPI ? "VBOX CD-ROM" : "VBOX HARDDISK");
+                    if (RT_FAILURE(rc))
+                    {
                         if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
-                        {
                             return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
                                        N_("PIIX3 configuration error: \"ModelNumber\" is longer than 40 bytes"));
-                        }
-                        else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
-                            return PDMDEV_SET_ERROR(pDevIns, rc,
-                                        N_("PIIX3 configuration error: failed to read \"ModelNumber\" as string"));
+                        return PDMDEV_SET_ERROR(pDevIns, rc,
+                                    N_("PIIX3 configuration error: failed to read \"ModelNumber\" as string"));
                     }
                 }
Index: trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp
===================================================================
--- trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp	(revision 15854)
+++ trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp	(revision 15855)
@@ -698,10 +698,10 @@
     GEN_CHECK_OFF(ATADevState, pControllerR0);
     GEN_CHECK_OFF(ATADevState, pControllerRC);
-    GEN_CHECK_OFF(ATADevState, achSerialNumber);
-    GEN_CHECK_OFF(ATADevState, achSerialNumber[ATA_SERIAL_NUMBER_LENGTH]);
-    GEN_CHECK_OFF(ATADevState, achFirmwareRevision);
-    GEN_CHECK_OFF(ATADevState, achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH]);
-    GEN_CHECK_OFF(ATADevState, achModelNumber);
-    GEN_CHECK_OFF(ATADevState, achModelNumber[ATA_MODEL_NUMBER_LENGTH]);
+    GEN_CHECK_OFF(ATADevState, szSerialNumber);
+    GEN_CHECK_OFF(ATADevState, szSerialNumber[ATA_SERIAL_NUMBER_LENGTH]);
+    GEN_CHECK_OFF(ATADevState, szFirmwareRevision);
+    GEN_CHECK_OFF(ATADevState, szFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH]);
+    GEN_CHECK_OFF(ATADevState, szModelNumber);
+    GEN_CHECK_OFF(ATADevState, szModelNumber[ATA_MODEL_NUMBER_LENGTH]);
     GEN_CHECK_SIZE(ATATransferRequest);
     GEN_CHECK_OFF(ATATransferRequest, iIf);
@@ -1143,10 +1143,10 @@
     GEN_CHECK_OFF(AHCIPort, fNotificationSend);
     GEN_CHECK_OFF(AHCIPort, fPortReset);
-    GEN_CHECK_OFF(AHCIPort, achSerialNumber);
-    GEN_CHECK_OFF(AHCIPort, achSerialNumber[AHCI_SERIAL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
-    GEN_CHECK_OFF(AHCIPort, achFirmwareRevision);
-    GEN_CHECK_OFF(AHCIPort, achFirmwareRevision[AHCI_FIRMWARE_REVISION_LENGTH]); /* One additional byte for the termination.*/
-    GEN_CHECK_OFF(AHCIPort, achModelNumber);
-    GEN_CHECK_OFF(AHCIPort, achModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
+    GEN_CHECK_OFF(AHCIPort, szSerialNumber);
+    GEN_CHECK_OFF(AHCIPort, szSerialNumber[AHCI_SERIAL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
+    GEN_CHECK_OFF(AHCIPort, szFirmwareRevision);
+    GEN_CHECK_OFF(AHCIPort, szFirmwareRevision[AHCI_FIRMWARE_REVISION_LENGTH]); /* One additional byte for the termination.*/
+    GEN_CHECK_OFF(AHCIPort, szModelNumber);
+    GEN_CHECK_OFF(AHCIPort, szModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
 
     GEN_CHECK_SIZE(AHCI);
