VirtualBox

Changeset 42349 in vbox for trunk/src


Ignore:
Timestamp:
Jul 24, 2012 11:11:47 AM (12 years ago)
Author:
vboxsync
Message:

Devices/Parallel: Addressing some of todos as identified by Knut.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp

    r42201 r42349  
    123123    uint8_t                       u8ReadInStatus;
    124124    /** Parallel port name */
    125     /** @todo r=bird: This is an array, they start with 'a'. However, this seems
    126      * to be a string, and they are not uint8_t but char and are prefixed with 'sz'
    127      * in char array form.
    128      *
    129      * Also, the use of tabs as indentation in anything but Makefiles is
    130      * forbidden.  That is not a guideline, it's the law. :-) (See above line.) */
    131     uint8_t                       u8ParportName[6];
     125    char                          szParportName[6];
    132126    /** Whether the parallel port is available or not. */
    133127    bool                          fParportAvail;
     
    423417    for (u32Idx = 0; SetupDiEnumDeviceInfo(hDevInfo, u32Idx, &DeviceInfoData); u32Idx++)
    424418    {
    425         uint32_t u32DataType; /** @todo r=bird: why do you use uint32_t here when the function wants a DWORD? */
     419        DWORD dwDataType;
    426420        uint8_t *pBuf = NULL;
    427         uint32_t u32BufSize = 0; /** @todo r=bird: ditto */
     421        DWORD dwBufSize = 0;
    428422
    429423        while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_FRIENDLYNAME,
    430                                                  (PDWORD)&u32DataType, (uint8_t *)pBuf,
    431                                                  u32BufSize, (PDWORD)&u32BufSize)
     424                                                 (PDWORD)&dwDataType, (uint8_t *)pBuf,
     425                                                 dwBufSize, (PDWORD)&dwBufSize)
    432426               && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
    433427        {
     
    435429                 RTMemFree(pBuf);
    436430            /* Max size will never be more than 2048 bytes */
    437             pBuf = (uint8_t *)RTMemAlloc(u32BufSize * 2);
     431            pBuf = (uint8_t *)RTMemAlloc(dwBufSize * 2);
    438432        }
    439433
    440434        if (pBuf) /** @todo r=bird: You're not checking errors here. */
    441435        {
    442             /** @todo r=bird: The indent of the block is wrong... More importantely, the
    443              * scope and purpose of the two variables would be clearer if you moved them
    444              * to the RTStrStr calls further down. */
    445              char *pCh = NULL;
    446              char* pTmpCh = NULL;
    447436             if (RTStrStr((char*)pBuf, "LPT"))
    448437             {
     
    451440                 {
    452441                     /* Find parallel port name and update the shared data struncture */
    453                      pCh = RTStrStr((char*)pBuf, "(");
    454                      pTmpCh = RTStrStr((char *)pBuf, ")");
     442                     char *pCh = RTStrStr((char*)pBuf, "(");
     443                     char *pTmpCh = RTStrStr((char *)pBuf, ")");
    455444                     /* check for the confirmation for the availability of parallel port */
    456445                     if (!(pCh && pTmpCh))
     
    465454                     }
    466455                     /* check for the confirmation for the availability of parallel port */
    467                      if (RTStrCopyEx((char *)(pThis->u8ParportName), sizeof(pThis->u8ParportName),
     456                     if (RTStrCopyEx((char *)(pThis->szParportName), sizeof(pThis->szParportName),
    468457                                      pCh+1, ((pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf)) - 1))
    469458                     {
     
    471460                         return VERR_NOT_FOUND;
    472461                     }
    473                      *((char *)pThis->u8ParportName + (pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf) + 1 ) = '\0';
     462                     *((char *)pThis->szParportName + (pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf) + 1 ) = '\0';
    474463
    475464                     /* checking again to make sure that we have got a valid name and in valid format too. */
    476                      if (RTStrNCmp((char *)pThis->u8ParportName, "LPT", 3)) {
     465                     if (RTStrNCmp((char *)pThis->szParportName, "LPT", 3)) {
    477466                         LogFlowFunc(("Parallel Port name \"LPT\" Not Found.\n"));
    478467                         return VERR_NOT_FOUND;
    479468                     }
    480469
    481                      /** @todo r=bird: Multiline expressions starts the next line with the
    482                       * operator, (instead of the previous line ending with an operator like you do
    483                       * here).
    484                       *
    485                       * Also, note that the opening curly brackets have it's own line in this
    486                       * file, so you do the same as the original author(s) of the file. */
    487                      if (!RTStrStr((char *)pThis->u8ParportName, "LPT") ||
    488                           !(pThis->u8ParportName[3] >= '0' && pThis->u8ParportName[3] <= '9')) {
    489                          RT_BZERO(pThis->u8ParportName, sizeof(pThis->u8ParportName));
     470                     if (!RTStrStr((char *)pThis->szParportName, "LPT")
     471                            || !(pThis->szParportName[3] >= '0'
     472                            && pThis->szParportName[3] <= '9'))
     473                     {
     474                         RT_BZERO(pThis->szParportName, sizeof(pThis->szParportName));
    490475                         LogFlowFunc(("Printer Port Name Not Found.\n"));
    491476                         return VERR_NOT_FOUND;
     
    1010995       Read and write will be done only if addresses are available
    1011996    */
    1012     if (pThis->u8ParportName)
    1013     {
    1014         LogFlowFunc(("Get the Handle to Printer Port =%s\n", (char *)pThis->u8ParportName));
     997    if (pThis->szParportName)
     998    {
     999        LogFlowFunc(("Get the Handle to Printer Port =%s\n", (char *)pThis->szParportName));
    10151000        /** @todo r=klaus convert to IPRT */
    1016         hPort = CreateFile((char *)pThis->u8ParportName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
     1001        hPort = CreateFile((char *)pThis->szParportName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
    10171002                           NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    10181003    }
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