- Timestamp:
- Jul 24, 2012 11:11:47 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp
r42201 r42349 123 123 uint8_t u8ReadInStatus; 124 124 /** 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]; 132 126 /** Whether the parallel port is available or not. */ 133 127 bool fParportAvail; … … 423 417 for (u32Idx = 0; SetupDiEnumDeviceInfo(hDevInfo, u32Idx, &DeviceInfoData); u32Idx++) 424 418 { 425 uint32_t u32DataType; /** @todo r=bird: why do you use uint32_t here when the function wants a DWORD? */419 DWORD dwDataType; 426 420 uint8_t *pBuf = NULL; 427 uint32_t u32BufSize = 0; /** @todo r=bird: ditto */421 DWORD dwBufSize = 0; 428 422 429 423 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) 432 426 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) 433 427 { … … 435 429 RTMemFree(pBuf); 436 430 /* Max size will never be more than 2048 bytes */ 437 pBuf = (uint8_t *)RTMemAlloc( u32BufSize * 2);431 pBuf = (uint8_t *)RTMemAlloc(dwBufSize * 2); 438 432 } 439 433 440 434 if (pBuf) /** @todo r=bird: You're not checking errors here. */ 441 435 { 442 /** @todo r=bird: The indent of the block is wrong... More importantely, the443 * scope and purpose of the two variables would be clearer if you moved them444 * to the RTStrStr calls further down. */445 char *pCh = NULL;446 char* pTmpCh = NULL;447 436 if (RTStrStr((char*)pBuf, "LPT")) 448 437 { … … 451 440 { 452 441 /* 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, ")"); 455 444 /* check for the confirmation for the availability of parallel port */ 456 445 if (!(pCh && pTmpCh)) … … 465 454 } 466 455 /* 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), 468 457 pCh+1, ((pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf)) - 1)) 469 458 { … … 471 460 return VERR_NOT_FOUND; 472 461 } 473 *((char *)pThis-> u8ParportName + (pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf) + 1 ) = '\0';462 *((char *)pThis->szParportName + (pTmpCh - (char *)pBuf) - (pCh - (char *)pBuf) + 1 ) = '\0'; 474 463 475 464 /* 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)) { 477 466 LogFlowFunc(("Parallel Port name \"LPT\" Not Found.\n")); 478 467 return VERR_NOT_FOUND; 479 468 } 480 469 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)); 490 475 LogFlowFunc(("Printer Port Name Not Found.\n")); 491 476 return VERR_NOT_FOUND; … … 1010 995 Read and write will be done only if addresses are available 1011 996 */ 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)); 1015 1000 /** @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, 1017 1002 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 1018 1003 }
Note:
See TracChangeset
for help on using the changeset viewer.