Changeset 62849 in vbox for trunk/src/VBox
- Timestamp:
- Aug 1, 2016 9:52:45 PM (8 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxControl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r62679 r62849 241 241 LONG (WINAPI * gpfnChangeDisplaySettingsEx)(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam); 242 242 243 static unsigned nextAdjacentRectXP (RECTL *paRects, unsigned nRects, unsigned iRect) 244 { 245 unsigned i; 246 for (i = 0; i < nRects; i++) 247 { 243 static unsigned nextAdjacentRectXP(RECTL const *paRects, unsigned cRects, unsigned iRect) 244 { 245 for (unsigned i = 0; i < cRects; i++) 248 246 if (paRects[iRect].right == paRects[i].left) 249 {250 247 return i; 251 } 252 } 253 return ~0; 254 } 255 256 static unsigned nextAdjacentRectXN (RECTL *paRects, unsigned nRects, unsigned iRect) 257 { 258 unsigned i; 259 for (i = 0; i < nRects; i++) 260 { 248 return ~0U; 249 } 250 251 static unsigned nextAdjacentRectXN(RECTL const *paRects, unsigned cRects, unsigned iRect) 252 { 253 for (unsigned i = 0; i < cRects; i++) 261 254 if (paRects[iRect].left == paRects[i].right) 262 {263 255 return i; 264 } 265 } 266 return ~0; 267 } 268 269 static unsigned nextAdjacentRectYP (RECTL *paRects, unsigned nRects, unsigned iRect) 270 { 271 unsigned i; 272 for (i = 0; i < nRects; i++) 273 { 256 return ~0U; 257 } 258 259 static unsigned nextAdjacentRectYP(RECTL const *paRects, unsigned cRects, unsigned iRect) 260 { 261 for (unsigned i = 0; i < cRects; i++) 274 262 if (paRects[iRect].bottom == paRects[i].top) 275 {276 263 return i; 277 } 278 } 279 return ~0; 280 } 281 282 unsigned nextAdjacentRectYN (RECTL *paRects, unsigned nRects, unsigned iRect) 283 { 284 unsigned i; 285 for (i = 0; i < nRects; i++) 286 { 264 return ~0U; 265 } 266 267 unsigned nextAdjacentRectYN(RECTL const *paRects, unsigned cRects, unsigned iRect) 268 { 269 for (unsigned i = 0; i < cRects; i++) 287 270 if (paRects[iRect].top == paRects[i].bottom) 288 {289 271 return i; 290 } 291 } 292 return ~0; 293 } 294 295 void resizeRect(RECTL *paRects, unsigned nRects, unsigned iPrimary, unsigned iResized, int NewWidth, int NewHeight) 296 { 297 RECTL *paNewRects = (RECTL *)alloca (sizeof (RECTL) * nRects); 298 memcpy (paNewRects, paRects, sizeof (RECTL) * nRects); 299 paNewRects[iResized].right += NewWidth - (paNewRects[iResized].right - paNewRects[iResized].left); 272 return ~0U; 273 } 274 275 void resizeRect(RECTL *paRects, unsigned cRects, unsigned iPrimary, unsigned iResized, int NewWidth, int NewHeight) 276 { 277 RECTL *paNewRects = (RECTL *)alloca(sizeof (RECTL) * cRects); 278 memcpy (paNewRects, paRects, sizeof(RECTL) * cRects); 279 paNewRects[iResized].right += NewWidth - (paNewRects[iResized].right - paNewRects[iResized].left); 300 280 paNewRects[iResized].bottom += NewHeight - (paNewRects[iResized].bottom - paNewRects[iResized].top); 301 281 … … 308 288 /* X positive. */ 309 289 unsigned iRect; 310 for (iRect = 0; iRect < nRects; iRect++)290 for (iRect = 0; iRect < cRects; iRect++) 311 291 { 312 292 /* Find the next adjacent original rect in x positive direction. */ 313 unsigned iNextRect = nextAdjacentRectXP (paRects, nRects, iRect);293 unsigned iNextRect = nextAdjacentRectXP (paRects, cRects, iRect); 314 294 Log(("next %d -> %d\n", iRect, iNextRect)); 315 295 … … 336 316 337 317 /* X negative. */ 338 for (iRect = 0; iRect < nRects; iRect++)318 for (iRect = 0; iRect < cRects; iRect++) 339 319 { 340 320 /* Find the next adjacent original rect in x negative direction. */ 341 unsigned iNextRect = nextAdjacentRectXN (paRects, nRects, iRect);321 unsigned iNextRect = nextAdjacentRectXN (paRects, cRects, iRect); 342 322 Log(("next %d -> %d\n", iRect, iNextRect)); 343 323 … … 364 344 365 345 /* Y positive (in the computer sense, top->down). */ 366 for (iRect = 0; iRect < nRects; iRect++)346 for (iRect = 0; iRect < cRects; iRect++) 367 347 { 368 348 /* Find the next adjacent original rect in y positive direction. */ 369 unsigned iNextRect = nextAdjacentRectYP (paRects, nRects, iRect);349 unsigned iNextRect = nextAdjacentRectYP (paRects, cRects, iRect); 370 350 Log(("next %d -> %d\n", iRect, iNextRect)); 371 351 … … 392 372 393 373 /* Y negative (in the computer sense, down->top). */ 394 for (iRect = 0; iRect < nRects; iRect++)374 for (iRect = 0; iRect < cRects; iRect++) 395 375 { 396 376 /* Find the next adjacent original rect in x negative direction. */ 397 unsigned iNextRect = nextAdjacentRectYN (paRects, nRects, iRect);377 unsigned iNextRect = nextAdjacentRectYN (paRects, cRects, iRect); 398 378 Log(("next %d -> %d\n", iRect, iNextRect)); 399 379 … … 419 399 } 420 400 421 memcpy (paRects, paNewRects, sizeof (RECTL) * nRects);401 memcpy (paRects, paNewRects, sizeof (RECTL) * cRects); 422 402 return; 423 403 } … … 429 409 430 410 DISPLAY_DEVICE DisplayDevice; 431 432 ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 411 RT_ZERO(DisplayDevice); 433 412 DisplayDevice.cb = sizeof(DisplayDevice); 434 413 … … 436 415 DWORD NumDevices = 0; 437 416 DWORD i = 0; 438 while (EnumDisplayDevices 417 while (EnumDisplayDevices(NULL, i, &DisplayDevice, 0)) 439 418 { 440 419 Log(("[%d] %s\n", i, DisplayDevice.DeviceName)); … … 442 421 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 443 422 { 444 Log(("Found primary device. err %d\n", GetLastError 423 Log(("Found primary device. err %d\n", GetLastError())); 445 424 NumDevices++; 446 425 } … … 448 427 { 449 428 450 Log(("Found secondary device. err %d\n", GetLastError 429 Log(("Found secondary device. err %d\n", GetLastError())); 451 430 NumDevices++; 452 431 } 453 432 454 ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));433 RT_ZERO(DisplayDevice); 455 434 DisplayDevice.cb = sizeof(DisplayDevice); 456 435 i++; 457 436 } 458 437 459 Log(("Found total %d devices. err %d\n", NumDevices, GetLastError 438 Log(("Found total %d devices. err %d\n", NumDevices, GetLastError())); 460 439 461 440 if (NumDevices == 0 || Id >= NumDevices) 462 441 { 463 Log(("Requested identifier %d is invalid. err %d\n", Id, GetLastError 442 Log(("Requested identifier %d is invalid. err %d\n", Id, GetLastError())); 464 443 return FALSE; 465 444 } 466 445 467 DISPLAY_DEVICE *paDisplayDevices = (DISPLAY_DEVICE *)alloca 468 DEVMODE *paDeviceModes = (DEVMODE *)alloca 469 RECTL *paRects = (RECTL *)alloca 446 DISPLAY_DEVICE *paDisplayDevices = (DISPLAY_DEVICE *)alloca(sizeof (DISPLAY_DEVICE) * NumDevices); 447 DEVMODE *paDeviceModes = (DEVMODE *)alloca(sizeof (DEVMODE) * NumDevices); 448 RECTL *paRects = (RECTL *)alloca(sizeof (RECTL) * NumDevices); 470 449 471 450 /* Fetch information about current devices and modes. */ … … 473 452 DWORD DevPrimaryNum = 0; 474 453 475 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));454 RT_ZERO(DisplayDevice); 476 455 DisplayDevice.cb = sizeof(DISPLAY_DEVICE); 477 456 … … 481 460 Log(("[%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName)); 482 461 483 BOOL bFetchDevice = FALSE;462 BOOL fFetchDevice = FALSE; 484 463 485 464 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 486 465 { 487 Log(("Found primary device. err %d\n", GetLastError 466 Log(("Found primary device. err %d\n", GetLastError())); 488 467 DevPrimaryNum = DevNum; 489 bFetchDevice = TRUE;468 fFetchDevice = TRUE; 490 469 } 491 470 else if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) 492 471 { 493 472 494 Log(("Found secondary device. err %d\n", GetLastError 495 bFetchDevice = TRUE;496 } 497 498 if ( bFetchDevice)473 Log(("Found secondary device. err %d\n", GetLastError())); 474 fFetchDevice = TRUE; 475 } 476 477 if (fFetchDevice) 499 478 { 500 479 if (DevNum >= NumDevices) … … 506 485 paDisplayDevices[DevNum] = DisplayDevice; 507 486 508 ZeroMemory(&paDeviceModes[DevNum], sizeof(DEVMODE));487 RT_BZERO(&paDeviceModes[DevNum], sizeof(DEVMODE)); 509 488 paDeviceModes[DevNum].dmSize = sizeof(DEVMODE); 510 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName, 511 ENUM_REGISTRY_SETTINGS, &paDeviceModes[DevNum])) 489 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName, ENUM_REGISTRY_SETTINGS, &paDeviceModes[DevNum])) 512 490 { 513 Log(("EnumDisplaySettings err %d\n", GetLastError 491 Log(("EnumDisplaySettings err %d\n", GetLastError())); 514 492 return FALSE; 515 493 } … … 528 506 } 529 507 530 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));508 RT_ZERO(DisplayDevice); 531 509 DisplayDevice.cb = sizeof(DISPLAY_DEVICE); 532 510 i++; … … 534 512 535 513 if (Width == 0) 536 {537 514 Width = paRects[Id].right - paRects[Id].left; 538 }539 515 540 516 if (Height == 0) 541 {542 517 Height = paRects[Id].bottom - paRects[Id].top; 543 }544 518 545 519 /* Check whether a mode reset or a change is requested. */ 546 520 if ( !fModeReset 547 && paRects[Id].right - paRects[Id].left == Width548 && paRects[Id].bottom - paRects[Id].top == Height521 && paRects[Id].right - paRects[Id].left == (LONG)Width 522 && paRects[Id].bottom - paRects[Id].top == (LONG)Height 549 523 && paDeviceModes[Id].dmBitsPerPel == BitsPerPixel) 550 524 { … … 554 528 555 529 resizeRect(paRects, NumDevices, DevPrimaryNum, Id, Width, Height); 556 #ifdef L og530 #ifdef LOG_ENABLED 557 531 for (i = 0; i < NumDevices; i++) 558 {559 532 Log(("[%d]: %d,%d %dx%d\n", 560 i, paRects[i].left, paRects[i].top, 561 paRects[i].right - paRects[i].left, 562 paRects[i].bottom - paRects[i].top)); 563 } 533 i, paRects[i].left, paRects[i].top, 534 paRects[i].right - paRects[i].left, 535 paRects[i].bottom - paRects[i].top)); 564 536 #endif /* Log */ 565 537 … … 568 540 */ 569 541 DEVMODE tempDevMode; 570 ZeroMemory (&tempDevMode, sizeof (tempDevMode));542 RT_ZERO(tempDevMode); 571 543 tempDevMode.dmSize = sizeof(DEVMODE); 572 544 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode); … … 591 563 gpfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 592 564 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 593 Log(("ChangeDisplaySettings position err %d\n", GetLastError 565 Log(("ChangeDisplaySettings position err %d\n", GetLastError())); 594 566 } 595 567 … … 619 591 DWORD bpp = atoi(argv[2]); 620 592 DWORD scr = 0; 621 622 593 if (argc == 4) 623 {624 594 scr = atoi(argv[3]); 625 }626 595 627 596 HMODULE hUser = GetModuleHandle("user32.dll"); 628 629 597 if (hUser) 630 598 { … … 635 603 { 636 604 /* The screen index is 0 based in the ResizeDisplayDevice call. */ 637 scr = scr > 0 ? scr - 1: 0;605 scr = scr > 0 ? scr - 1 : 0; 638 606 639 607 /* Horizontal resolution must be a multiple of 8, round down. */ … … 655 623 static int checkVBoxVideoKey(HKEY hkeyVideo) 656 624 { 657 char szValue[128]; 658 DWORD len = sizeof(szValue); 659 DWORD dwKeyType; 660 LONG status = RegQueryValueExA(hkeyVideo, "Device Description", NULL, &dwKeyType, 661 (LPBYTE)szValue, &len); 662 625 RTUTF16 wszValue[128]; 626 DWORD cbValue = sizeof(wszValue); 627 DWORD dwKeyType; 628 LONG status = RegQueryValueExW(hkeyVideo, L"Device Description", NULL, &dwKeyType, (LPBYTE)wszValue, &cbValue); 663 629 if (status == ERROR_SUCCESS) 664 630 { 665 631 /* WDDM has additional chars after "Adapter" */ 666 static char s szDeviceDescription[] = "VirtualBox Graphics Adapter";667 if (_strnicmp(szValue, sszDeviceDescription, sizeof(sszDeviceDescription) - sizeof(char)) == 0)668 {632 static char s_szDeviceDescription[] = "VirtualBox Graphics Adapter"; 633 wszValue[sizeof(s_szDeviceDescription) - 1] = '\0'; 634 if (RTUtf16ICmpAscii(wszValue, s_szDeviceDescription) == 0) 669 635 return VINF_SUCCESS; 670 }671 636 } 672 637 … … 694 659 695 660 /* Get the 'ObjectNumberList' */ 696 ULONG numDevices = 0;661 ULONG cDevices = 0; 697 662 DWORD adwObjectNumberList[256]; 698 DWORD len= sizeof(adwObjectNumberList);699 status = RegQueryValueExA(hkeyDeviceMap, "ObjectNumberList", NULL, &dwKeyType, (LPBYTE)&adwObjectNumberList[0], & len);663 DWORD cbValue = sizeof(adwObjectNumberList); 664 status = RegQueryValueExA(hkeyDeviceMap, "ObjectNumberList", NULL, &dwKeyType, (LPBYTE)&adwObjectNumberList[0], &cbValue); 700 665 701 666 if ( status == ERROR_SUCCESS 702 667 && dwKeyType == REG_BINARY) 703 { 704 numDevices = len / sizeof(DWORD); 705 } 668 cDevices = cbValue / sizeof(DWORD); 706 669 else 707 670 { 708 671 /* The list might not exists. Use 'MaxObjectNumber' REG_DWORD and build a list. */ 709 672 DWORD dwMaxObjectNumber = 0; 710 len = sizeof(dwMaxObjectNumber); 711 status = RegQueryValueExA(hkeyDeviceMap, "MaxObjectNumber", NULL, &dwKeyType, (LPBYTE)&dwMaxObjectNumber, &len); 712 673 cbValue = sizeof(dwMaxObjectNumber); 674 status = RegQueryValueExA(hkeyDeviceMap, "MaxObjectNumber", NULL, &dwKeyType, (LPBYTE)&dwMaxObjectNumber, &cbValue); 713 675 if ( status == ERROR_SUCCESS 714 676 && dwKeyType == REG_DWORD) 715 677 { 716 678 /* 'MaxObjectNumber' is inclusive. */ 717 numDevices = RT_MIN(dwMaxObjectNumber + 1, RT_ELEMENTS(adwObjectNumberList)); 718 for (iDevice = 0; iDevice < numDevices; iDevice++) 719 { 679 cDevices = RT_MIN(dwMaxObjectNumber + 1, RT_ELEMENTS(adwObjectNumberList)); 680 for (iDevice = 0; iDevice < cDevices; iDevice++) 720 681 adwObjectNumberList[iDevice] = iDevice; 721 }722 682 } 723 683 } 724 684 725 if ( numDevices == 0)685 if (cDevices == 0) 726 686 { 727 687 /* Always try '\Device\Video0' as the old code did. Enum can be used in this case in principle. */ 728 688 adwObjectNumberList[0] = 0; 729 numDevices = 1;689 cDevices = 1; 730 690 } 731 691 732 692 /* Scan device entries */ 733 for (iDevice = 0; iDevice < numDevices; iDevice++)693 for (iDevice = 0; iDevice < cDevices; iDevice++) 734 694 { 735 695 char szValueName[64]; … … 737 697 738 698 char szVideoLocation[256]; 739 len= sizeof(szVideoLocation);740 status = RegQueryValueExA(hkeyDeviceMap, szValueName, NULL, &dwKeyType, (LPBYTE)&szVideoLocation[0], & len);699 cbValue = sizeof(szVideoLocation); 700 status = RegQueryValueExA(hkeyDeviceMap, szValueName, NULL, &dwKeyType, (LPBYTE)&szVideoLocation[0], &cbValue); 741 701 742 702 /* This value starts with '\REGISTRY\Machine' */ … … 773 733 static DECLCALLBACK(RTEXITCODE) handleGetVideoAcceleration(int argc, char *argv[]) 774 734 { 735 RT_NOREF2(argc, argv); 775 736 ULONG status; 776 737 HKEY hkeyVideo = getVideoKey(false); … … 780 741 /* query the actual value */ 781 742 DWORD fAcceleration = 1; 782 DWORD len= sizeof(fAcceleration);743 DWORD cbValue = sizeof(fAcceleration); 783 744 DWORD dwKeyType; 784 status = RegQueryValueExA(hkeyVideo, "EnableVideoAccel", NULL, &dwKeyType, (LPBYTE)&fAcceleration, & len);745 status = RegQueryValueExA(hkeyVideo, "EnableVideoAccel", NULL, &dwKeyType, (LPBYTE)&fAcceleration, &cbValue); 785 746 if (status != ERROR_SUCCESS) 786 747 RTPrintf("Video acceleration: default\n"); … … 831 792 { 832 793 DWORD dwFlags = 0; 833 DWORD len= sizeof(dwFlags);794 DWORD cbValue = sizeof(dwFlags); 834 795 DWORD dwKeyType; 835 ULONG status = RegQueryValueExA(hkeyVideo, "VBoxVideoFlags", NULL, &dwKeyType, (LPBYTE)&dwFlags, & len);796 ULONG status = RegQueryValueExA(hkeyVideo, "VBoxVideoFlags", NULL, &dwKeyType, (LPBYTE)&dwFlags, &cbValue); 836 797 if (status != ERROR_SUCCESS) 837 798 RTPrintf("Video flags: default\n"); … … 883 844 { 884 845 DWORD dwFlags = 0; 885 DWORD len= sizeof(dwFlags);846 DWORD cbValue = sizeof(dwFlags); 886 847 DWORD dwKeyType; 887 ULONG status = RegQueryValueExA(hkeyVideo, "VBoxVideoFlags", NULL, &dwKeyType, (LPBYTE)&dwFlags, & len);848 ULONG status = RegQueryValueExA(hkeyVideo, "VBoxVideoFlags", NULL, &dwKeyType, (LPBYTE)&dwFlags, &cbValue); 888 849 if (status != ERROR_SUCCESS) 889 {890 850 dwFlags = 0; 891 } 892 893 dwFlags = fSet? (dwFlags | u32Mask): 894 (dwFlags & ~u32Mask); 851 852 dwFlags = fSet ? dwFlags | u32Mask : dwFlags & ~u32Mask; 895 853 896 854 status = RegSetValueExA(hkeyVideo, "VBoxVideoFlags", 0, REG_DWORD, (LPBYTE)&dwFlags, sizeof(dwFlags)); … … 1064 1022 static DECLCALLBACK(RTEXITCODE) handleListCustomModes(int argc, char *argv[]) 1065 1023 { 1024 RT_NOREF1(argv); 1066 1025 if (argc != 0) 1067 1026 { … … 1202 1161 1203 1162 bool fVerbose = false; 1204 if ( 2 == argc1163 if ( argc == 2 1205 1164 && ( strcmp(argv[1], "-verbose") == 0 1206 1165 || strcmp(argv[1], "--verbose") == 0) … … 1237 1196 * hope. Actually this should never go wrong, as we are generous 1238 1197 * enough with buffer space. */ 1239 bool f inish= false;1240 for (unsigned i = 0; (i < 10) && !finish; ++i)1198 bool fFinished = false; 1199 for (unsigned i = 0; i < 10 && !fFinished; ++i) 1241 1200 { 1242 1201 void *pvTmpBuf = RTMemRealloc(pvBuf, cbBuf); … … 1257 1216 cbBuf += 1024; 1258 1217 else 1259 f inish= true;1218 fFinished = true; 1260 1219 } 1261 1220 if (VERR_TOO_MUCH_DATA == rc) … … 1300 1259 * arguments. 1301 1260 */ 1302 bool usageOK = true;1261 bool fUsageOK = true; 1303 1262 const char *pszName = NULL; 1304 1263 const char *pszValue = NULL; … … 1309 1268 } 1310 1269 else if (3 == argc) 1311 usageOK = false;1270 fUsageOK = false; 1312 1271 else if (4 == argc) 1313 1272 { … … 1315 1274 if ( strcmp(argv[2], "-flags") != 0 1316 1275 && strcmp(argv[2], "--flags") != 0) 1317 usageOK = false;1276 fUsageOK = false; 1318 1277 pszFlags = argv[3]; 1319 1278 } 1320 1279 else if (argc != 1) 1321 usageOK = false;1322 if (! usageOK)1280 fUsageOK = false; 1281 if (!fUsageOK) 1323 1282 { 1324 1283 usage(GUEST_PROP); … … 1365 1324 * arguments. 1366 1325 */ 1367 bool usageOK = true;1326 bool fUsageOK = true; 1368 1327 const char *pszName = NULL; 1369 1328 if (argc < 1) 1370 usageOK = false;1371 if (! usageOK)1329 fUsageOK = false; 1330 if (!fUsageOK) 1372 1331 { 1373 1332 usage(GUEST_PROP); … … 1481 1440 uint64_t u64TimestampIn = 0; 1482 1441 uint32_t u32Timeout = RT_INDEFINITE_WAIT; 1483 bool usageOK = true;1442 bool fUsageOK = true; 1484 1443 if (argc < 1) 1485 usageOK = false;1444 fUsageOK = false; 1486 1445 pszPatterns = argv[0]; 1487 for (int i = 1; usageOK && i < argc; ++i)1446 for (int i = 1; fUsageOK && i < argc; ++i) 1488 1447 { 1489 1448 if ( strcmp(argv[i], "-timeout") == 0 … … 1494 1453 != VINF_SUCCESS 1495 1454 ) 1496 usageOK = false;1455 fUsageOK = false; 1497 1456 else 1498 1457 ++i; … … 1505 1464 != VINF_SUCCESS 1506 1465 ) 1507 usageOK = false;1466 fUsageOK = false; 1508 1467 else 1509 1468 ++i; 1510 1469 } 1511 1470 else 1512 usageOK = false;1513 } 1514 if (! usageOK)1471 fUsageOK = false; 1472 } 1473 if (!fUsageOK) 1515 1474 { 1516 1475 usage(GUEST_PROP); … … 1543 1502 * hope. Actually this should never go wrong, as we are generous 1544 1503 * enough with buffer space. */ 1545 bool finish = false; 1546 for (unsigned i = 0; 1547 (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW) && !finish && (i < 10); 1548 ++i) 1504 bool fFinished = false; 1505 for (unsigned i = 0; (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW) && !fFinished && i < 10; i++) 1549 1506 { 1550 1507 void *pvTmpBuf = RTMemRealloc(pvBuf, cbBuf); … … 1566 1523 cbBuf += 1024; 1567 1524 else 1568 f inish= true;1525 fFinished = true; 1569 1526 if (rc == VERR_TOO_MUCH_DATA) 1570 1527 VBoxControlError("Temporarily unable to get a notification\n"); … … 1608 1565 static DECLCALLBACK(RTEXITCODE) handleGuestProperty(int argc, char *argv[]) 1609 1566 { 1610 if ( 0 == argc)1567 if (argc == 0) 1611 1568 { 1612 1569 usage(GUEST_PROP); … … 1615 1572 if (!strcmp(argv[0], "get")) 1616 1573 return getGuestProperty(argc - 1, argv + 1); 1617 elseif (!strcmp(argv[0], "set"))1574 if (!strcmp(argv[0], "set")) 1618 1575 return setGuestProperty(argc - 1, argv + 1); 1619 elseif (!strcmp(argv[0], "delete") || !strcmp(argv[0], "unset"))1576 if (!strcmp(argv[0], "delete") || !strcmp(argv[0], "unset")) 1620 1577 return deleteGuestProperty(argc - 1, argv + 1); 1621 elseif (!strcmp(argv[0], "enumerate"))1578 if (!strcmp(argv[0], "enumerate")) 1622 1579 return enumGuestProperty(argc - 1, argv + 1); 1623 elseif (!strcmp(argv[0], "wait"))1580 if (!strcmp(argv[0], "wait")) 1624 1581 return waitGuestProperty(argc - 1, argv + 1); 1625 /* else*/1582 /* unknown cmd */ 1626 1583 usage(GUEST_PROP); 1627 1584 return RTEXITCODE_FAILURE; … … 1635 1592 static RTEXITCODE listSharedFolders(int argc, char **argv) 1636 1593 { 1637 bool usageOK = true;1594 bool fUsageOK = true; 1638 1595 bool fOnlyShowAutoMount = false; 1639 1596 if (argc == 1) … … 1643 1600 fOnlyShowAutoMount = true; 1644 1601 else 1645 usageOK = false;1602 fUsageOK = false; 1646 1603 } 1647 1604 else if (argc > 1) 1648 usageOK = false; 1649 1650 if (!usageOK) 1605 fUsageOK = false; 1606 if (!fUsageOK) 1651 1607 { 1652 1608 usage(GUEST_SHAREDFOLDERS); … … 1662 1618 PVBGLR3SHAREDFOLDERMAPPING paMappings; 1663 1619 uint32_t cMappings; 1664 rc = VbglR3SharedFolderGetMappings(u32ClientId, fOnlyShowAutoMount, 1665 &paMappings, &cMappings); 1620 rc = VbglR3SharedFolderGetMappings(u32ClientId, fOnlyShowAutoMount, &paMappings, &cMappings); 1666 1621 if (RT_SUCCESS(rc)) 1667 1622 { … … 1704 1659 static DECLCALLBACK(RTEXITCODE) handleSharedFolder(int argc, char *argv[]) 1705 1660 { 1706 if ( 0 == argc)1661 if (argc == 0) 1707 1662 { 1708 1663 usage(GUEST_SHAREDFOLDERS); … … 1723 1678 static DECLCALLBACK(RTEXITCODE) handleWriteCoreDump(int argc, char *argv[]) 1724 1679 { 1680 RT_NOREF2(argc, argv); 1725 1681 int rc = VbglR3WriteCoreDump(); 1726 1682 if (RT_SUCCESS(rc)) … … 1831 1787 static DECLCALLBACK(RTEXITCODE) handleTakeSnapshot(int argc, char *argv[]) 1832 1788 { 1833 //VbglR3VmTakeSnapshot(argv[0], argv[1]);1789 RT_NOREF2(argc, argv); //VbglR3VmTakeSnapshot(argv[0], argv[1]); 1834 1790 return VBoxControlError("not implemented"); 1835 1791 } … … 1840 1796 static DECLCALLBACK(RTEXITCODE) handleSaveState(int argc, char *argv[]) 1841 1797 { 1842 //VbglR3VmSaveState();1798 RT_NOREF2(argc, argv); //VbglR3VmSaveState(); 1843 1799 return VBoxControlError("not implemented"); 1844 1800 } … … 1849 1805 static DECLCALLBACK(RTEXITCODE) handleSuspend(int argc, char *argv[]) 1850 1806 { 1851 //VbglR3VmSuspend();1807 RT_NOREF2(argc, argv); //VbglR3VmSuspend(); 1852 1808 return VBoxControlError("not implemented"); 1853 1809 } … … 1858 1814 static DECLCALLBACK(RTEXITCODE) handlePowerOff(int argc, char *argv[]) 1859 1815 { 1860 //VbglR3VmPowerOff();1816 RT_NOREF2(argc, argv); //VbglR3VmPowerOff(); 1861 1817 return VBoxControlError("not implemented"); 1862 1818 } … … 1867 1823 static DECLCALLBACK(RTEXITCODE) handleVersion(int argc, char *argv[]) 1868 1824 { 1825 RT_NOREF1(argv); 1869 1826 if (argc) 1870 1827 return VBoxControlSyntaxError("getversion does not take any arguments"); … … 1877 1834 static DECLCALLBACK(RTEXITCODE) handleHelp(int argc, char *argv[]) 1878 1835 { 1879 /* ignore arguments for now. */1836 RT_NOREF2(argc, argv); /* ignore arguments for now. */ 1880 1837 usage(); 1881 1838 return RTEXITCODE_SUCCESS; -
trunk/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp
r62521 r62849 83 83 uint32_t *pcbBufActual) 84 84 { 85 RT_NOREF2(pvBuf, cbBuf); 85 86 RTPrintf("Called GET_PROP, client %d, name %s...\n", 86 87 idClient, pszName); … … 120 121 char const **ppszFlags) 121 122 { 123 RT_NOREF2(ppaszPatterns, cPatterns); 122 124 RTPrintf("Called ENUM_PROPS, client %d...\n", idClient); 123 125 AssertPtrReturn(ppHandle, VERR_INVALID_POINTER); … … 144 146 char const **ppszFlags) 145 147 { 148 RT_NOREF1(pHandle); 146 149 RTPrintf("Called enumerate next...\n"); 147 150 AssertReturn(VALID_PTR(ppszName) || VALID_PTR(ppszValue) || VALID_PTR(ppszFlags), … … 160 163 VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle) 161 164 { 165 RT_NOREF1(pHandle); 162 166 RTPrintf("Called enumerate free...\n"); 163 167 } … … 175 179 uint32_t *pcbBufActual) 176 180 { 181 RT_NOREF2(pvBuf, cbBuf); 177 182 if (u32Timeout == RT_INDEFINITE_WAIT) 178 183 RTPrintf("Called GET_NOTIFICATION, client %d, patterns %s, timestamp %llu,\n"
Note:
See TracChangeset
for help on using the changeset viewer.