VirtualBox

Changeset 15855 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 8, 2009 11:09:10 AM (16 years ago)
Author:
vboxsync
Message:

DevAHCI,DevATA: ach -> sz and use CFGMR3QueryStringDef (bad idea to assume CFGMR3QueryString won't touch the buffer if no value).

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

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

    r15847 r15855  
    282282
    283283    /** The serial numnber to use for IDENTIFY DEVICE commands. */
    284     char                                achSerialNumber[ATA_SERIAL_NUMBER_LENGTH+1];
     284    char                                szSerialNumber[ATA_SERIAL_NUMBER_LENGTH+1];
    285285    /** The firmware revision to use for IDENTIFY DEVICE commands. */
    286     char                                achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH+1];
     286    char                                szFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH+1];
    287287    /** The model number to use for IDENTIFY DEVICE commands. */
    288     char                                achModelNumber[ATA_MODEL_NUMBER_LENGTH+1];
     288    char                                szModelNumber[ATA_MODEL_NUMBER_LENGTH+1];
    289289
    290290#if HC_ARCH_BITS == 64
     
    11131113    p[5] = RT_H2LE_U16(512);
    11141114    p[6] = RT_H2LE_U16(s->PCHSGeometry.cSectors);
    1115     ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
     1115    ataPadString((uint8_t *)(p + 10), s->szSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
    11161116    p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */
    11171117    p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */
    11181118    p[22] = RT_H2LE_U16(0); /* ECC bytes per sector */
    1119     ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
    1120     ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
     1119    ataPadString((uint8_t *)(p + 23), s->szFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
     1120    ataPadString((uint8_t *)(p + 27), s->szModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
    11211121#if ATA_MAX_MULT_SECTORS > 1
    11221122    p[47] = RT_H2LE_U16(0x8000 | ATA_MAX_MULT_SECTORS);
     
    12191219    /* Removable CDROM, 50us response, 12 byte packets */
    12201220    p[0] = RT_H2LE_U16(2 << 14 | 5 << 8 | 1 << 7 | 2 << 5 | 0 << 0);
    1221     ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
     1221    ataPadString((uint8_t *)(p + 10), s->szSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
    12221222    p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */
    12231223    p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */
    1224     ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
    1225     ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
     1224    ataPadString((uint8_t *)(p + 23), s->szFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
     1225    ataPadString((uint8_t *)(p + 27), s->szModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
    12261226    p[49] = RT_H2LE_U16(1 << 11 | 1 << 9 | 1 << 8); /* DMA and LBA supported */
    12271227    p[50] = RT_H2LE_U16(1 << 14);  /* No drive specific standby timer minimum */
     
    43034303        {
    43044304            rc = RTSemEventWait(pCtl->SuspendIOSem, RT_INDEFINITE_WAIT);
    4305             /* Continue if we got a signal by RTThreadPoke(). 
     4305            /* Continue if we got a signal by RTThreadPoke().
    43064306             * We will get notified if there is a request to process.
    43074307             */
     
    43204320            rc = RTSemEventWait(pCtl->AsyncIOSem, RT_INDEFINITE_WAIT);
    43214321            LogBird(("ata: %x: waking up\n", pCtl->IOPortBase1));
    4322             /* Continue if we got a signal by RTThreadPoke(). 
     4322            /* Continue if we got a signal by RTThreadPoke().
    43234323             * We will get notified if there is a request to process.
    43244324             */
     
    63526352                        { "SecondaryMaster", "SecondarySlave" }
    63536353                    };
    6354                     char aSerial[ATA_SERIAL_NUMBER_LENGTH+1];
     6354
     6355                    /* Generate a default serial number. */
     6356                    char szSerial[ATA_SERIAL_NUMBER_LENGTH+1];
    63556357                    RTUUID Uuid;
    63566358                    if (pIf->pDrvBlock)
     
    63626364                    {
    63636365                        /* Generate a predictable serial for drives which don't have a UUID. */
    6364                         RTStrPrintf(aSerial, sizeof(aSerial), "VB%x-%04x%04x",
     6366                        RTStrPrintf(szSerial, sizeof(szSerial), "VB%x-%04x%04x",
    63656367                                    pIf->iLUN + pDevIns->iInstance * 32,
    63666368                                    pThis->aCts[i].IOPortBase1, pThis->aCts[i].IOPortBase2);
    63676369                    }
    63686370                    else
    6369                         RTStrPrintf(aSerial, sizeof(aSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]);
    6370                     strncpy(pIf->achSerialNumber, aSerial, sizeof(pIf->achSerialNumber));
    6371                     strncpy(pIf->achFirmwareRevision, "1.0", sizeof(pIf->achSerialNumber));
    6372                     if (pIf->fATAPI)
    6373                         strncpy(pIf->achModelNumber, "VBOX CD-ROM", sizeof(pIf->achModelNumber));
    6374                     else
    6375                         strncpy(pIf->achModelNumber, "VBOX HARDDISK", sizeof(pIf->achModelNumber));
    6376 
    6377                     /* Check if the user provided some values to overwrite. */
     6371                        RTStrPrintf(szSerial, sizeof(szSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]);
     6372
     6373                    /* Get user config if present using defaults otherwise. */
    63786374                    PCFGMNODE pCfgNode = CFGMR3GetChild(pCfgHandle, s_apszCFGMKeys[i][j]);
    6379                     if (pCfgNode)
     6375                    rc = CFGMR3QueryStringDef(pCfgNode, "SerialNumber", pIf->szSerialNumber, sizeof(pIf->szSerialNumber),
     6376                                              szSerial);
     6377                    if (RT_FAILURE(rc))
    63806378                    {
    6381                         rc = CFGMR3QueryString(pCfgNode, "SerialNumber", pIf->achSerialNumber, sizeof(pIf->achSerialNumber));
    63826379                        if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
    6383                         {
    63846380                            return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
    63856381                                        N_("PIIX3 configuration error: \"SerialNumber\" is longer than 20 bytes"));
    6386                         }
    6387                         else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
    6388                             return PDMDEV_SET_ERROR(pDevIns, rc,
    6389                                         N_("PIIX3 configuration error: failed to read \"SerialNumber\" as string"));
    6390 
    6391                         rc = CFGMR3QueryString(pCfgNode, "FirmwareRevision", pIf->achFirmwareRevision, sizeof(pIf->achFirmwareRevision));
     6382                        return PDMDEV_SET_ERROR(pDevIns, rc,
     6383                                  N_("PIIX3 configuration error: failed to read \"SerialNumber\" as string"));
     6384                    }
     6385
     6386                    rc = CFGMR3QueryStringDef(pCfgNode, "FirmwareRevision", pIf->szFirmwareRevision, sizeof(pIf->szFirmwareRevision),
     6387                                              "1.0");
     6388                    if (RT_FAILURE(rc))
     6389                    {
    63926390                        if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
    6393                         {
    63946391                            return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
    63956392                                        N_("PIIX3 configuration error: \"FirmwareRevision\" is longer than 8 bytes"));
    6396                         }
    6397                         else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
    6398                             return PDMDEV_SET_ERROR(pDevIns, rc,
    6399                                         N_("PIIX3 configuration error: failed to read \"FirmwareRevision\" as string"));
    6400 
    6401                         rc = CFGMR3QueryString(pCfgNode, "ModelNumber", pIf->achModelNumber, sizeof(pIf->achModelNumber));
     6393                        return PDMDEV_SET_ERROR(pDevIns, rc,
     6394                                    N_("PIIX3 configuration error: failed to read \"FirmwareRevision\" as string"));
     6395                    }
     6396
     6397                    rc = CFGMR3QueryStringDef(pCfgNode, "ModelNumber", pIf->szModelNumber, sizeof(pIf->szModelNumber),
     6398                                              pIf->fATAPI ? "VBOX CD-ROM" : "VBOX HARDDISK");
     6399                    if (RT_FAILURE(rc))
     6400                    {
    64026401                        if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
    6403                         {
    64046402                            return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
    64056403                                       N_("PIIX3 configuration error: \"ModelNumber\" is longer than 40 bytes"));
    6406                         }
    6407                         else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
    6408                             return PDMDEV_SET_ERROR(pDevIns, rc,
    6409                                         N_("PIIX3 configuration error: failed to read \"ModelNumber\" as string"));
     6404                        return PDMDEV_SET_ERROR(pDevIns, rc,
     6405                                    N_("PIIX3 configuration error: failed to read \"ModelNumber\" as string"));
    64106406                    }
    64116407                }
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp

    r15846 r15855  
    698698    GEN_CHECK_OFF(ATADevState, pControllerR0);
    699699    GEN_CHECK_OFF(ATADevState, pControllerRC);
    700     GEN_CHECK_OFF(ATADevState, achSerialNumber);
    701     GEN_CHECK_OFF(ATADevState, achSerialNumber[ATA_SERIAL_NUMBER_LENGTH]);
    702     GEN_CHECK_OFF(ATADevState, achFirmwareRevision);
    703     GEN_CHECK_OFF(ATADevState, achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH]);
    704     GEN_CHECK_OFF(ATADevState, achModelNumber);
    705     GEN_CHECK_OFF(ATADevState, achModelNumber[ATA_MODEL_NUMBER_LENGTH]);
     700    GEN_CHECK_OFF(ATADevState, szSerialNumber);
     701    GEN_CHECK_OFF(ATADevState, szSerialNumber[ATA_SERIAL_NUMBER_LENGTH]);
     702    GEN_CHECK_OFF(ATADevState, szFirmwareRevision);
     703    GEN_CHECK_OFF(ATADevState, szFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH]);
     704    GEN_CHECK_OFF(ATADevState, szModelNumber);
     705    GEN_CHECK_OFF(ATADevState, szModelNumber[ATA_MODEL_NUMBER_LENGTH]);
    706706    GEN_CHECK_SIZE(ATATransferRequest);
    707707    GEN_CHECK_OFF(ATATransferRequest, iIf);
     
    11431143    GEN_CHECK_OFF(AHCIPort, fNotificationSend);
    11441144    GEN_CHECK_OFF(AHCIPort, fPortReset);
    1145     GEN_CHECK_OFF(AHCIPort, achSerialNumber);
    1146     GEN_CHECK_OFF(AHCIPort, achSerialNumber[AHCI_SERIAL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
    1147     GEN_CHECK_OFF(AHCIPort, achFirmwareRevision);
    1148     GEN_CHECK_OFF(AHCIPort, achFirmwareRevision[AHCI_FIRMWARE_REVISION_LENGTH]); /* One additional byte for the termination.*/
    1149     GEN_CHECK_OFF(AHCIPort, achModelNumber);
    1150     GEN_CHECK_OFF(AHCIPort, achModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
     1145    GEN_CHECK_OFF(AHCIPort, szSerialNumber);
     1146    GEN_CHECK_OFF(AHCIPort, szSerialNumber[AHCI_SERIAL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
     1147    GEN_CHECK_OFF(AHCIPort, szFirmwareRevision);
     1148    GEN_CHECK_OFF(AHCIPort, szFirmwareRevision[AHCI_FIRMWARE_REVISION_LENGTH]); /* One additional byte for the termination.*/
     1149    GEN_CHECK_OFF(AHCIPort, szModelNumber);
     1150    GEN_CHECK_OFF(AHCIPort, szModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
    11511151
    11521152    GEN_CHECK_SIZE(AHCI);
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