- Timestamp:
- Jan 25, 2023 2:23:33 AM (21 months ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 1 added
- 11 edited
-
.scm-settings (added)
-
VBoxInternalManage.cpp (modified) (25 diffs)
-
VBoxManageAppliance.cpp (modified) (40 diffs)
-
VBoxManageBandwidthControl.cpp (modified) (1 diff)
-
VBoxManageCloudMachine.cpp (modified) (23 diffs)
-
VBoxManageControlVM.cpp (modified) (1 diff)
-
VBoxManageDebugVM.cpp (modified) (19 diffs)
-
VBoxManageDisk.cpp (modified) (31 diffs)
-
VBoxManageGuestCtrl.cpp (modified) (14 diffs)
-
VBoxManageMisc.cpp (modified) (6 diffs)
-
VBoxManageModifyVM.cpp (modified) (2 diffs)
-
VBoxManageSnapshot.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r98103 r98298 355 355 * 356 356 * @param enmCommand The command. 357 * @param rcThe RTGetOpt return code.357 * @param vrc The RTGetOpt return code. 358 358 * @param pValueUnion The value union. 359 359 */ 360 static RTEXITCODE errorGetOptInternal(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion)360 static RTEXITCODE errorGetOptInternal(USAGECATEGORY enmCommand, int vrc, union RTGETOPTUNION const *pValueUnion) 361 361 { 362 362 /* 363 363 * Check if it is an unhandled standard option. 364 364 */ 365 if ( rc == 'V')365 if (vrc == 'V') 366 366 { 367 367 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision()); … … 369 369 } 370 370 371 if ( rc == 'h')371 if (vrc == 'h') 372 372 { 373 373 showLogo(g_pStdErr); … … 383 383 printUsageInternal(enmCommand, g_pStdErr); 384 384 385 if ( rc == VINF_GETOPT_NOT_OPTION)385 if (vrc == VINF_GETOPT_NOT_OPTION) 386 386 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Invalid parameter '%s'"), pValueUnion->psz); 387 if ( rc > 0)388 { 389 if (RT_C_IS_PRINT( rc))390 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Invalid option -%c"), rc);391 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Invalid option case %i"), rc);392 } 393 if ( rc == VERR_GETOPT_UNKNOWN_OPTION)387 if (vrc > 0) 388 { 389 if (RT_C_IS_PRINT(vrc)) 390 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Invalid option -%c"), vrc); 391 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Invalid option case %i"), vrc); 392 } 393 if (vrc == VERR_GETOPT_UNKNOWN_OPTION) 394 394 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Unknown option: %s"), pValueUnion->psz); 395 if ( rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)395 if (vrc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT) 396 396 return RTMsgErrorExit(RTEXITCODE_SYNTAX, Internal::tr("Invalid argument format: %s"), pValueUnion->psz); 397 397 if (pValueUnion->pDef) 398 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);399 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);398 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, vrc); 399 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", vrc); 400 400 } 401 401 … … 496 496 497 497 char *pszKeys; 498 int rc = RTUtf16ToUtf8(Keys.raw(), &pszKeys);499 if (RT_SUCCESS( rc))498 int vrc = RTUtf16ToUtf8(Keys.raw(), &pszKeys); 499 if (RT_SUCCESS(vrc)) 500 500 { 501 501 /* locate it */ … … 531 531 else 532 532 RTMsgError(Internal::tr("Failed to delete key '%s' from '%s', string conversion error %Rrc!"), 533 pszKey, pszKeyBase, rc);533 pszKey, pszKeyBase, vrc); 534 534 535 535 return E_FAIL; … … 630 630 int vrc = RTStrToInt64Ex(argv[2], NULL, 0, &offDelta); 631 631 if (RT_FAILURE(vrc)) 632 return errorArgument(argv[0], Internal::tr("Failed to read delta '%s', rc=%Rrc\n"), argv[2], vrc);632 return errorArgument(argv[0], Internal::tr("Failed to read delta '%s', vrc=%Rrc\n"), argv[2], vrc); 633 633 } 634 634 … … 642 642 int vrc = RTStrToUInt64Ex(argv[4], NULL, 0, &ModuleAddress); 643 643 if (RT_FAILURE(vrc)) 644 return errorArgument(argv[0], Internal::tr("Failed to read module address '%s', rc=%Rrc\n"), argv[4], vrc);644 return errorArgument(argv[0], Internal::tr("Failed to read module address '%s', vrc=%Rrc\n"), argv[4], vrc); 645 645 } 646 646 … … 650 650 int vrc = RTStrToUInt64Ex(argv[5], NULL, 0, &ModuleSize); 651 651 if (RT_FAILURE(vrc)) 652 return errorArgument(argv[0], Internal::tr("Failed to read module size '%s', rc=%Rrc\n"), argv[5], vrc);652 return errorArgument(argv[0], Internal::tr("Failed to read module size '%s', vrc=%Rrc\n"), argv[5], vrc); 653 653 } 654 654 … … 707 707 int vrc = RTStrToUInt64Ex(argv[2], NULL, 0, &ModuleAddress); 708 708 if (RT_FAILURE(vrc)) 709 return errorArgument(argv[0], Internal::tr("Failed to read module address '%s', rc=%Rrc\n"), argv[2], vrc);709 return errorArgument(argv[0], Internal::tr("Failed to read module address '%s', vrc=%Rrc\n"), argv[2], vrc); 710 710 711 711 /* name (optional) */ … … 718 718 vrc = RTStrToUInt64Ex(argv[4], NULL, 0, &offSubtrahend); 719 719 if (RT_FAILURE(vrc)) 720 return errorArgument(argv[0], Internal::tr("Failed to read subtrahend '%s', rc=%Rrc\n"), argv[4], vrc);720 return errorArgument(argv[0], Internal::tr("Failed to read subtrahend '%s', vrc=%Rrc\n"), argv[4], vrc); 721 721 } 722 722 … … 726 726 vrc = RTStrToUInt32Ex(argv[5], NULL, 0, &iSeg); 727 727 if (RT_FAILURE(vrc)) 728 return errorArgument(argv[0], Internal::tr("Failed to read segment number '%s', rc=%Rrc\n"), argv[5], vrc);728 return errorArgument(argv[0], Internal::tr("Failed to read segment number '%s', vrc=%Rrc\n"), argv[5], vrc); 729 729 } 730 730 … … 749 749 750 750 751 static DECLCALLBACK(void) handleVDError(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)751 static DECLCALLBACK(void) handleVDError(void *pvUser, int vrc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) 752 752 { 753 753 RT_NOREF(pvUser); 754 754 RTMsgErrorV(pszFormat, va); 755 RTMsgError(Internal::tr("Error code %Rrc at %s(%u) in function %s"), rc, RT_SRC_POS_ARGS);755 RTMsgError(Internal::tr("Error code %Rrc at %s(%u) in function %s"), vrc, RT_SRC_POS_ARGS); 756 756 } 757 757 … … 801 801 char *pszFormat = NULL; 802 802 VDTYPE enmType = VDTYPE_INVALID; 803 int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 804 argv[1], VDTYPE_INVALID, &pszFormat, &enmType); 805 if (RT_FAILURE(rc)) 806 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Format autodetect failed: %Rrc"), rc); 803 int vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, argv[1], VDTYPE_INVALID, &pszFormat, &enmType); 804 if (RT_FAILURE(vrc)) 805 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Format autodetect failed: %Rrc"), vrc); 807 806 808 807 PVDISK pDisk = NULL; … … 813 812 vdInterfaceError.pfnMessage = handleVDMessage; 814 813 815 rc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR,816 NULL, sizeof(VDINTERFACEERROR), &pVDIfs);817 AssertRC( rc);818 819 rc = VDCreate(pVDIfs, enmType, &pDisk);820 if (RT_FAILURE( rc))821 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot create the virtual disk container: %Rrc"), rc);814 vrc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR, 815 NULL, sizeof(VDINTERFACEERROR), &pVDIfs); 816 AssertRC(vrc); 817 818 vrc = VDCreate(pVDIfs, enmType, &pDisk); 819 if (RT_FAILURE(vrc)) 820 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot create the virtual disk container: %Rrc"), vrc); 822 821 823 822 /* Open the image */ 824 rc = VDOpen(pDisk, pszFormat, argv[1], VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_INFO, NULL);825 if (RT_FAILURE( rc))826 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot open the image: %Rrc"), rc);823 vrc = VDOpen(pDisk, pszFormat, argv[1], VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_INFO, NULL); 824 if (RT_FAILURE(vrc)) 825 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot open the image: %Rrc"), vrc); 827 826 828 827 if (uuidType == HDUUID) 829 rc = VDSetUuid(pDisk, VD_LAST_IMAGE, uuid.raw());828 vrc = VDSetUuid(pDisk, VD_LAST_IMAGE, uuid.raw()); 830 829 else 831 rc = VDSetParentUuid(pDisk, VD_LAST_IMAGE, uuid.raw());832 if (RT_FAILURE( rc))833 RTMsgError(Internal::tr("Cannot set a new UUID: %Rrc"), rc);830 vrc = VDSetParentUuid(pDisk, VD_LAST_IMAGE, uuid.raw()); 831 if (RT_FAILURE(vrc)) 832 RTMsgError(Internal::tr("Cannot set a new UUID: %Rrc"), vrc); 834 833 else 835 834 RTPrintf(Internal::tr("UUID changed to: %s\n"), uuid.toString().c_str()); … … 837 836 VDCloseAll(pDisk); 838 837 839 return RT_SUCCESS( rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;838 return RT_SUCCESS(vrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 840 839 } 841 840 … … 854 853 char *pszFormat = NULL; 855 854 VDTYPE enmType = VDTYPE_INVALID; 856 int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 857 argv[0], VDTYPE_INVALID, &pszFormat, &enmType); 858 if (RT_FAILURE(rc)) 859 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Format autodetect failed: %Rrc"), rc); 855 int vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, argv[0], VDTYPE_INVALID, &pszFormat, &enmType); 856 if (RT_FAILURE(vrc)) 857 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Format autodetect failed: %Rrc"), vrc); 860 858 861 859 PVDISK pDisk = NULL; … … 866 864 vdInterfaceError.pfnMessage = handleVDMessage; 867 865 868 rc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR,869 NULL, sizeof(VDINTERFACEERROR), &pVDIfs);870 AssertRC( rc);871 872 rc = VDCreate(pVDIfs, enmType, &pDisk);873 if (RT_FAILURE( rc))874 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot create the virtual disk container: %Rrc"), rc);866 vrc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR, 867 NULL, sizeof(VDINTERFACEERROR), &pVDIfs); 868 AssertRC(vrc); 869 870 vrc = VDCreate(pVDIfs, enmType, &pDisk); 871 if (RT_FAILURE(vrc)) 872 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot create the virtual disk container: %Rrc"), vrc); 875 873 876 874 /* Open the image */ 877 rc = VDOpen(pDisk, pszFormat, argv[0], VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO, NULL);878 if (RT_FAILURE( rc))879 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot open the image: %Rrc"), rc);875 vrc = VDOpen(pDisk, pszFormat, argv[0], VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO, NULL); 876 if (RT_FAILURE(vrc)) 877 return RTMsgErrorExit(RTEXITCODE_FAILURE, Internal::tr("Cannot open the image: %Rrc"), vrc); 880 878 881 879 VDDumpImages(pDisk); … … 883 881 VDCloseAll(pDisk); 884 882 885 return RT_SUCCESS( rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;883 return RT_SUCCESS(vrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 886 884 } 887 885 … … 892 890 uint32_t sector_size = 512; 893 891 uint64_t lastUsableLBA = 0; 894 int rc;895 892 896 893 VDISKPARTTYPE partitioningType; … … 899 896 memset(pPart->aPartitions, '\0', sizeof(pPart->aPartitions)); 900 897 901 rc = RTFileReadAt(File, 0, &aBuffer, sizeof(aBuffer), NULL);902 if (RT_FAILURE( rc))903 return rc;898 int vrc = RTFileReadAt(File, 0, &aBuffer, sizeof(aBuffer), NULL); 899 if (RT_FAILURE(vrc)) 900 return vrc; 904 901 905 902 if (aBuffer[450] == 0xEE)/* check the sign of the GPT disk*/ … … 911 908 return VERR_INVALID_PARAMETER; 912 909 913 rc = RTFileReadAt(File, sector_size, &partitionTableHeader, sector_size, NULL);914 if (RT_SUCCESS( rc))910 vrc = RTFileReadAt(File, sector_size, &partitionTableHeader, sector_size, NULL); 911 if (RT_SUCCESS(vrc)) 915 912 { 916 913 /** @todo r=bird: This is a 64-bit magic value, right... */ … … 971 968 /* partition entries begin from LBA2 */ 972 969 /** @todo r=aeichner: Reading from LBA 2 is not always correct, the header will contain the starting LBA. */ 973 rc = RTFileReadAt(File, 1024, pbPartTable, RT_ALIGN_Z(partitionEntrySize * partitionsNumber, 512), NULL);974 if (RT_FAILURE( rc))970 vrc = RTFileReadAt(File, 1024, pbPartTable, RT_ALIGN_Z(partitionEntrySize * partitionsNumber, 512), NULL); 971 if (RT_FAILURE(vrc)) 975 972 { 976 973 RTMsgError(Internal::tr("Reading the partition table failed")); 977 974 RTMemFree(pbPartTable); 978 return rc;975 return vrc; 979 976 } 980 977 … … 1082 1079 do 1083 1080 { 1084 rc = RTFileReadAt(File, (uStart + uOffset) * 512, &aBuffer, sizeof(aBuffer), NULL);1085 if (RT_FAILURE( rc))1086 return rc;1081 vrc = RTFileReadAt(File, (uStart + uOffset) * 512, &aBuffer, sizeof(aBuffer), NULL); 1082 if (RT_FAILURE(vrc)) 1083 return vrc; 1087 1084 1088 1085 if (aBuffer[510] != 0x55 || aBuffer[511] != 0xaa) … … 1831 1828 static RTEXITCODE CmdModUninstall(void) 1832 1829 { 1833 int rc = SUPR3Uninstall();1834 if (RT_SUCCESS( rc) ||rc == VERR_NOT_IMPLEMENTED)1830 int vrc = SUPR3Uninstall(); 1831 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_IMPLEMENTED) 1835 1832 return RTEXITCODE_SUCCESS; 1836 1833 return RTEXITCODE_FAILURE; … … 1844 1841 static RTEXITCODE CmdModInstall(void) 1845 1842 { 1846 int rc = SUPR3Install();1847 if (RT_SUCCESS( rc) ||rc == VERR_NOT_IMPLEMENTED)1843 int vrc = SUPR3Install(); 1844 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_IMPLEMENTED) 1848 1845 return RTEXITCODE_SUCCESS; 1849 1846 return RTEXITCODE_FAILURE; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp
r98103 r98298 100 100 static int parseImportOptions(const char *psz, com::SafeArray<ImportOptions_T> *options) 101 101 { 102 int rc = VINF_SUCCESS;103 while (psz && *psz && RT_SUCCESS( rc))102 int vrc = VINF_SUCCESS; 103 while (psz && *psz && RT_SUCCESS(vrc)) 104 104 { 105 105 size_t len; … … 118 118 options->push_back(ImportOptions_ImportToVDI); 119 119 else 120 rc = VERR_PARSE_ERROR;120 vrc = VERR_PARSE_ERROR; 121 121 } 122 122 if (pszComma) … … 126 126 } 127 127 128 return rc;128 return vrc; 129 129 } 130 130 … … 1427 1427 static int parseExportOptions(const char *psz, com::SafeArray<ExportOptions_T> *options) 1428 1428 { 1429 int rc = VINF_SUCCESS;1430 while (psz && *psz && RT_SUCCESS( rc))1429 int vrc = VINF_SUCCESS; 1430 while (psz && *psz && RT_SUCCESS(vrc)) 1431 1431 { 1432 1432 size_t len; … … 1455 1455 options->push_back(ExportOptions_StripAllNonNATMACs); 1456 1456 else 1457 rc = VERR_PARSE_ERROR;1457 vrc = VERR_PARSE_ERROR; 1458 1458 } 1459 1459 if (pszComma) … … 1463 1463 } 1464 1464 1465 return rc;1465 return vrc; 1466 1466 } 1467 1467 … … 2122 2122 */ 2123 2123 RTVFSFILE hVfsFileOva; 2124 int rc = RTVfsFileOpenNormal(pszOva, RTFILE_O_OPEN | RTFILE_O_READWRITE | RTFILE_O_DENY_WRITE, &hVfsFileOva);2125 if (RT_FAILURE( rc))2126 return RTMsgErrorExitFailure(Appliance::tr("Failed to open OVA '%s' for updating: %Rrc"), pszOva, rc);2124 int vrc = RTVfsFileOpenNormal(pszOva, RTFILE_O_OPEN | RTFILE_O_READWRITE | RTFILE_O_DENY_WRITE, &hVfsFileOva); 2125 if (RT_FAILURE(vrc)) 2126 return RTMsgErrorExitFailure(Appliance::tr("Failed to open OVA '%s' for updating: %Rrc"), pszOva, vrc); 2127 2127 2128 2128 RTVFSFSSTREAM hVfsFssOva; 2129 rc = RTZipTarFsStreamForFile(hVfsFileOva, RTZIPTARFORMAT_DEFAULT, RTZIPTAR_C_UPDATE, &hVfsFssOva);2129 vrc = RTZipTarFsStreamForFile(hVfsFileOva, RTZIPTARFORMAT_DEFAULT, RTZIPTAR_C_UPDATE, &hVfsFssOva); 2130 2130 RTVfsFileRelease(hVfsFileOva); 2131 if (RT_FAILURE( rc))2132 return RTMsgErrorExitFailure(Appliance::tr("Failed to open OVA '%s' as a TAR file: %Rrc"), pszOva, rc);2131 if (RT_FAILURE(vrc)) 2132 return RTMsgErrorExitFailure(Appliance::tr("Failed to open OVA '%s' as a TAR file: %Rrc"), pszOva, vrc); 2133 2133 *phVfsFssOva = hVfsFssOva; 2134 2134 … … 2147 2147 RTVFSOBJTYPE enmType; 2148 2148 RTVFSOBJ hVfsObj; 2149 rc = RTVfsFsStrmNext(hVfsFssOva, &pszName, &enmType, &hVfsObj);2150 if (RT_FAILURE( rc))2149 vrc = RTVfsFsStrmNext(hVfsFssOva, &pszName, &enmType, &hVfsObj); 2150 if (RT_FAILURE(vrc)) 2151 2151 { 2152 if ( rc == VERR_EOF)2153 rc = VINF_SUCCESS;2152 if (vrc == VERR_EOF) 2153 vrc = VINF_SUCCESS; 2154 2154 else 2155 RTMsgError(Appliance::tr("RTVfsFsStrmNext returned %Rrc"), rc);2155 RTMsgError(Appliance::tr("RTVfsFsStrmNext returned %Rrc"), vrc); 2156 2156 break; 2157 2157 } … … 2169 2169 { 2170 2170 if (*phVfsManifest != NIL_RTVFSFILE) 2171 rc = RTMsgErrorRc(VERR_DUPLICATE, Appliance::tr("OVA contains multiple manifests! first: %s second: %s"),2172 pStrManifestName->c_str(), pszName);2171 vrc = RTMsgErrorRc(VERR_DUPLICATE, Appliance::tr("OVA contains multiple manifests! first: %s second: %s"), 2172 pStrManifestName->c_str(), pszName); 2173 2173 else if (pszSignatureName) 2174 rc = RTMsgErrorRc(VERR_WRONG_ORDER,2175 Appliance::tr("Unsupported OVA file ordering! Signature file ('%s') as succeeded by '%s'."),2176 pszSignatureName, pszName);2174 vrc = RTMsgErrorRc(VERR_WRONG_ORDER, 2175 Appliance::tr("Unsupported OVA file ordering! Signature file ('%s') as succeeded by '%s'."), 2176 pszSignatureName, pszName); 2177 2177 else 2178 2178 { 2179 2179 if (iVerbosity >= 2) 2180 2180 RTMsgInfo(Appliance::tr("Found manifest file: %s"), pszName); 2181 rc = pStrManifestName->assignNoThrow(pszName);2182 if (RT_SUCCESS( rc))2181 vrc = pStrManifestName->assignNoThrow(pszName); 2182 if (RT_SUCCESS(vrc)) 2183 2183 { 2184 2184 RTVFSIOSTREAM hVfsIos = RTVfsObjToIoStream(hVfsObj); 2185 2185 Assert(hVfsIos != NIL_RTVFSIOSTREAM); 2186 rc = RTVfsMemorizeIoStreamAsFile(hVfsIos, RTFILE_O_READ, phVfsManifest);2186 vrc = RTVfsMemorizeIoStreamAsFile(hVfsIos, RTFILE_O_READ, phVfsManifest); 2187 2187 RTVfsIoStrmRelease(hVfsIos); /* consumes stream handle. */ 2188 if (RT_FAILURE( rc))2189 rc = RTMsgErrorRc(VERR_DUPLICATE, Appliance::tr("Failed to memorize the manifest: %Rrc"),rc);2188 if (RT_FAILURE(vrc)) 2189 vrc = RTMsgErrorRc(VERR_DUPLICATE, Appliance::tr("Failed to memorize the manifest: %Rrc"), vrc); 2190 2190 } 2191 2191 else … … 2198 2198 { 2199 2199 if (*phVfsOldSignature != NIL_RTVFSOBJ) 2200 rc = RTMsgErrorRc(VERR_WRONG_ORDER, Appliance::tr("Multiple signature files! (%s)"), pszName);2200 vrc = RTMsgErrorRc(VERR_WRONG_ORDER, Appliance::tr("Multiple signature files! (%s)"), pszName); 2201 2201 else 2202 2202 { … … 2210 2210 } 2211 2211 else if (pszSignatureName) 2212 rc = RTMsgErrorRc(VERR_WRONG_ORDER,2213 Appliance::tr("Unsupported OVA file ordering! Signature file ('%s') as succeeded by '%s'."),2214 pszSignatureName, pszName);2212 vrc = RTMsgErrorRc(VERR_WRONG_ORDER, 2213 Appliance::tr("Unsupported OVA file ordering! Signature file ('%s') as succeeded by '%s'."), 2214 pszSignatureName, pszName); 2215 2215 2216 2216 /* … … 2219 2219 RTVfsObjRelease(hVfsObj); 2220 2220 RTStrFree(pszName); 2221 if (RT_FAILURE( rc))2221 if (RT_FAILURE(vrc)) 2222 2222 break; 2223 2223 } … … 2226 2226 * Complain if no manifest. 2227 2227 */ 2228 if (RT_SUCCESS( rc) && *phVfsManifest == NIL_RTVFSFILE)2229 rc = RTMsgErrorRc(VERR_NOT_FOUND, Appliance::tr("The OVA contains no manifest and cannot be signed!"));2230 else if (RT_SUCCESS( rc) && *phVfsOldSignature != NIL_RTVFSOBJ && !fReSign)2231 rc = RTMsgErrorRc(VERR_ALREADY_EXISTS,2232 Appliance::tr("The OVA is already signed ('%s')! (Use the --force option to force re-signing it.)"),2233 pszSignatureName);2228 if (RT_SUCCESS(vrc) && *phVfsManifest == NIL_RTVFSFILE) 2229 vrc = RTMsgErrorRc(VERR_NOT_FOUND, Appliance::tr("The OVA contains no manifest and cannot be signed!")); 2230 else if (RT_SUCCESS(vrc) && *phVfsOldSignature != NIL_RTVFSOBJ && !fReSign) 2231 vrc = RTMsgErrorRc(VERR_ALREADY_EXISTS, 2232 Appliance::tr("The OVA is already signed ('%s')! (Use the --force option to force re-signing it.)"), 2233 pszSignatureName); 2234 2234 2235 2235 RTStrFree(pszSignatureName); 2236 return rc;2236 return vrc; 2237 2237 } 2238 2238 … … 2255 2255 * Truncate the file at the old signature, if present. 2256 2256 */ 2257 int rc;2257 int vrc; 2258 2258 if (hVfsOldSignature != NIL_RTVFSOBJ) 2259 2259 { 2260 rc = RTZipTarFsStreamTruncate(hVfsFssOva, hVfsOldSignature, false /*fAfter*/);2261 if (RT_FAILURE( rc))2262 return RTMsgErrorRc( rc, Appliance::tr("RTZipTarFsStreamTruncate failed on '%s': %Rrc"), pszOva,rc);2260 vrc = RTZipTarFsStreamTruncate(hVfsFssOva, hVfsOldSignature, false /*fAfter*/); 2261 if (RT_FAILURE(vrc)) 2262 return RTMsgErrorRc(vrc, Appliance::tr("RTZipTarFsStreamTruncate failed on '%s': %Rrc"), pszOva, vrc); 2263 2263 } 2264 2264 … … 2267 2267 * we'll end up with VERR_EOF, probably not a great idea... 2268 2268 */ 2269 rc = RTVfsFileSeek(hVfsFileSignature, 0, RTFILE_SEEK_BEGIN, NULL);2270 if (RT_FAILURE( rc))2271 return RTMsgErrorRc( rc, Appliance::tr("RTVfsFileSeek(hVfsFileSignature) failed: %Rrc"),rc);2269 vrc = RTVfsFileSeek(hVfsFileSignature, 0, RTFILE_SEEK_BEGIN, NULL); 2270 if (RT_FAILURE(vrc)) 2271 return RTMsgErrorRc(vrc, Appliance::tr("RTVfsFileSeek(hVfsFileSignature) failed: %Rrc"), vrc); 2272 2272 2273 2273 RTVFSOBJ hVfsObj = RTVfsObjFromFile(hVfsFileSignature); 2274 rc = RTVfsFsStrmAdd(hVfsFssOva, pszSignatureName, hVfsObj, 0 /*fFlags*/);2274 vrc = RTVfsFsStrmAdd(hVfsFssOva, pszSignatureName, hVfsObj, 0 /*fFlags*/); 2275 2275 RTVfsObjRelease(hVfsObj); 2276 if (RT_FAILURE( rc))2277 return RTMsgErrorRc( rc, Appliance::tr("RTVfsFsStrmAdd('%s') failed on '%s': %Rrc"), pszSignatureName, pszOva,rc);2276 if (RT_FAILURE(vrc)) 2277 return RTMsgErrorRc(vrc, Appliance::tr("RTVfsFsStrmAdd('%s') failed on '%s': %Rrc"), pszSignatureName, pszOva, vrc); 2278 2278 2279 2279 /* 2280 2280 * Terminate the file system stream. 2281 2281 */ 2282 rc = RTVfsFsStrmEnd(hVfsFssOva);2283 if (RT_FAILURE( rc))2284 return RTMsgErrorRc( rc, Appliance::tr("RTVfsFsStrmEnd failed on '%s': %Rrc"), pszOva,rc);2282 vrc = RTVfsFsStrmEnd(hVfsFssOva); 2283 if (RT_FAILURE(vrc)) 2284 return RTMsgErrorRc(vrc, Appliance::tr("RTVfsFsStrmEnd failed on '%s': %Rrc"), pszOva, vrc); 2285 2285 2286 2286 return VINF_SUCCESS; … … 2294 2294 unsigned iVerbosity, const char *pszTag, PRTERRINFOSTATIC pErrInfo) 2295 2295 { 2296 int rc;2296 int vrc; 2297 2297 2298 2298 /* … … 2311 2311 * Check that things add up. 2312 2312 */ 2313 rc = RTCrPkcs7SignedData_CheckSanity(pSignedData,2314 RTCRPKCS7SIGNEDDATA_SANITY_F_ONLY_KNOWN_HASH2315 | RTCRPKCS7SIGNEDDATA_SANITY_F_SIGNING_CERT_PRESENT,2316 RTErrInfoInitStatic(pErrInfo), "SD");2317 if (RT_SUCCESS( rc))2313 vrc = RTCrPkcs7SignedData_CheckSanity(pSignedData, 2314 RTCRPKCS7SIGNEDDATA_SANITY_F_ONLY_KNOWN_HASH 2315 | RTCRPKCS7SIGNEDDATA_SANITY_F_SIGNING_CERT_PRESENT, 2316 RTErrInfoInitStatic(pErrInfo), "SD"); 2317 if (RT_SUCCESS(vrc)) 2318 2318 { 2319 2319 if (iVerbosity > 2 && pszTag == NULL) … … 2325 2325 */ 2326 2326 RTTIMESPEC Now; 2327 rc = RTCrPkcs7VerifySignedDataWithExternalData(pContentInfo, RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS,2328 NIL_RTCRSTORE /*hAdditionalCerts*/,2329 NIL_RTCRSTORE /*hTrustedCerts*/,2330 RTTimeNow(&Now),2331 NULL /*pfnVerifyCert*/, NULL /*pvUser*/,2332 pvManifest, cbManifest, RTErrInfoInitStatic(pErrInfo));2333 if (RT_SUCCESS( rc))2327 vrc = RTCrPkcs7VerifySignedDataWithExternalData(pContentInfo, RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS, 2328 NIL_RTCRSTORE /*hAdditionalCerts*/, 2329 NIL_RTCRSTORE /*hTrustedCerts*/, 2330 RTTimeNow(&Now), 2331 NULL /*pfnVerifyCert*/, NULL /*pvUser*/, 2332 pvManifest, cbManifest, RTErrInfoInitStatic(pErrInfo)); 2333 if (RT_SUCCESS(vrc)) 2334 2334 { 2335 2335 if (iVerbosity > 1 && pszTag != NULL) … … 2337 2337 } 2338 2338 else 2339 rc = RTMsgErrorRc(rc, Appliance::tr("Failed to verify the PKCS#7/CMS signature: %Rrc%RTeim"),2340 rc, &pErrInfo->Core);2339 vrc = RTMsgErrorRc(vrc, Appliance::tr("Failed to verify the PKCS#7/CMS signature: %Rrc%RTeim"), 2340 vrc, &pErrInfo->Core); 2341 2341 } 2342 2342 else 2343 2343 RTMsgError(Appliance::tr("RTCrPkcs7SignedData_CheckSanity failed on PKCS#7/CMS signature: %Rrc%RTeim"), 2344 rc, &pErrInfo->Core);2344 vrc, &pErrInfo->Core); 2345 2345 2346 2346 } 2347 2347 else 2348 rc = RTMsgErrorRc(VERR_WRONG_TYPE, Appliance::tr("PKCS#7/CMS signature inner ContentType isn't 'data' but: %s"),2349 pSignedData->ContentInfo.ContentType.szObjId);2348 vrc = RTMsgErrorRc(VERR_WRONG_TYPE, Appliance::tr("PKCS#7/CMS signature inner ContentType isn't 'data' but: %s"), 2349 pSignedData->ContentInfo.ContentType.szObjId); 2350 2350 } 2351 2351 else 2352 rc = RTMsgErrorRc(VERR_WRONG_TYPE, Appliance::tr("PKCS#7/CMD signature is not 'signedData': %s"),2353 pContentInfo->ContentType.szObjId);2354 return rc;2352 vrc = RTMsgErrorRc(VERR_WRONG_TYPE, Appliance::tr("PKCS#7/CMD signature is not 'signedData': %s"), 2353 pContentInfo->ContentType.szObjId); 2354 return vrc; 2355 2355 } 2356 2356 … … 2370 2370 RTCRPKCS7CONTENTINFO ContentInfo; 2371 2371 RT_ZERO(ContentInfo); 2372 int rc = RTCrPkcs7ContentInfo_DecodeAsn1(&PrimaryCursor.Cursor, 0, &ContentInfo, "CI");2373 if (RT_SUCCESS( rc))2372 int vrc = RTCrPkcs7ContentInfo_DecodeAsn1(&PrimaryCursor.Cursor, 0, &ContentInfo, "CI"); 2373 if (RT_SUCCESS(vrc)) 2374 2374 { 2375 2375 if (iVerbosity > 5) 2376 2376 RTAsn1Dump(&ContentInfo.SeqCore.Asn1Core, 0 /*fFlags*/, 0 /*uLevel*/, RTStrmDumpPrintfV, g_pStdOut); 2377 2377 2378 rc = doCheckPkcs7SignatureWorker(&ContentInfo, pvManifest, cbManifest, iVerbosity, NULL, pErrInfo);2379 if (RT_SUCCESS( rc))2378 vrc = doCheckPkcs7SignatureWorker(&ContentInfo, pvManifest, cbManifest, iVerbosity, NULL, pErrInfo); 2379 if (RT_SUCCESS(vrc)) 2380 2380 { 2381 2381 /* … … 2384 2384 */ 2385 2385 RTCRPKCS7CONTENTINFO ContentInfo2; 2386 rc = RTCrPkcs7ContentInfo_Clone(&ContentInfo2, &ContentInfo, &g_RTAsn1DefaultAllocator);2387 if (RT_SUCCESS( rc))2386 vrc = RTCrPkcs7ContentInfo_Clone(&ContentInfo2, &ContentInfo, &g_RTAsn1DefaultAllocator); 2387 if (RT_SUCCESS(vrc)) 2388 2388 { 2389 rc = doCheckPkcs7SignatureWorker(&ContentInfo2, pvManifest, cbManifest, iVerbosity, "cloned", pErrInfo);2389 vrc = doCheckPkcs7SignatureWorker(&ContentInfo2, pvManifest, cbManifest, iVerbosity, "cloned", pErrInfo); 2390 2390 RTCrPkcs7ContentInfo_Delete(&ContentInfo2); 2391 2391 } 2392 2392 else 2393 rc = RTMsgErrorRc(rc, Appliance::tr("RTCrPkcs7ContentInfo_Clone failed: %Rrc"),rc);2393 vrc = RTMsgErrorRc(vrc, Appliance::tr("RTCrPkcs7ContentInfo_Clone failed: %Rrc"), vrc); 2394 2394 } 2395 2395 } 2396 2396 else 2397 2397 RTMsgError(Appliance::tr("RTCrPkcs7ContentInfo_DecodeAsn1 failed to decode PKCS#7/CMS signature: %Rrc%RTemi"), 2398 rc, &pErrInfo->Core);2398 vrc, &pErrInfo->Core); 2399 2399 2400 2400 RTCrPkcs7ContentInfo_Delete(&ContentInfo); 2401 return rc;2401 return vrc; 2402 2402 } 2403 2403 … … 2414 2414 * Add a blank line, just for good measure. 2415 2415 */ 2416 int rc = RTVfsFileWrite(hVfsFileSignature, "\n", 1, NULL);2417 if (RT_FAILURE( rc))2418 return RTMsgErrorRc( rc, "RTVfsFileWrite/signature: %Rrc",rc);2416 int vrc = RTVfsFileWrite(hVfsFileSignature, "\n", 1, NULL); 2417 if (RT_FAILURE(vrc)) 2418 return RTMsgErrorRc(vrc, "RTVfsFileWrite/signature: %Rrc", vrc); 2419 2419 2420 2420 /* … … 2422 2422 */ 2423 2423 uint64_t cbManifest; 2424 rc = RTVfsFileQuerySize(hVfsFileManifest, &cbManifest);2425 if (RT_FAILURE( rc))2426 return RTMsgErrorRc( rc, "RTVfsFileQuerySize/manifest: %Rrc",rc);2424 vrc = RTVfsFileQuerySize(hVfsFileManifest, &cbManifest); 2425 if (RT_FAILURE(vrc)) 2426 return RTMsgErrorRc(vrc, "RTVfsFileQuerySize/manifest: %Rrc", vrc); 2427 2427 if (cbManifest > _4M) 2428 2428 return RTMsgErrorRc(VERR_OUT_OF_RANGE, Appliance::tr("Manifest is too big: %#RX64 bytes, max 4MiB", "", cbManifest), … … 2433 2433 return RTMsgErrorRc(VERR_NO_MEMORY, Appliance::tr("Out of memory!")); 2434 2434 2435 rc = RTVfsFileReadAt(hVfsFileManifest, 0, pvManifest, (size_t)cbManifest, NULL);2436 if (RT_SUCCESS( rc))2435 vrc = RTVfsFileReadAt(hVfsFileManifest, 0, pvManifest, (size_t)cbManifest, NULL); 2436 if (RT_SUCCESS(vrc)) 2437 2437 { 2438 2438 /* … … 2442 2442 if (cIntermediateCerts) 2443 2443 { 2444 rc = RTCrStoreCreateInMem(&hIntermediateCerts, cIntermediateCerts);2445 if (RT_SUCCESS( rc))2444 vrc = RTCrStoreCreateInMem(&hIntermediateCerts, cIntermediateCerts); 2445 if (RT_SUCCESS(vrc)) 2446 2446 { 2447 2447 for (unsigned i = 0; i < cIntermediateCerts; i++) 2448 2448 { 2449 2449 const char *pszFile = papszIntermediateCerts[i]; 2450 rc = RTCrStoreCertAddFromFile(hIntermediateCerts, 0 /*fFlags*/, pszFile, &pErrInfo->Core);2451 if (RT_FAILURE( rc))2450 vrc = RTCrStoreCertAddFromFile(hIntermediateCerts, 0 /*fFlags*/, pszFile, &pErrInfo->Core); 2451 if (RT_FAILURE(vrc)) 2452 2452 { 2453 RTMsgError(Appliance::tr("RTCrStoreCertAddFromFile failed on '%s': %Rrc%#RTeim"), pszFile, rc, &pErrInfo->Core); 2453 RTMsgError(Appliance::tr("RTCrStoreCertAddFromFile failed on '%s': %Rrc%#RTeim"), 2454 pszFile, vrc, &pErrInfo->Core); 2454 2455 break; 2455 2456 } … … 2457 2458 } 2458 2459 else 2459 RTMsgError(Appliance::tr("RTCrStoreCreateInMem failed: %Rrc"), rc);2460 RTMsgError(Appliance::tr("RTCrStoreCreateInMem failed: %Rrc"), vrc); 2460 2461 } 2461 if (RT_SUCCESS( rc))2462 if (RT_SUCCESS(vrc)) 2462 2463 { 2463 2464 /* … … 2465 2466 */ 2466 2467 size_t cbResult = 0; 2467 rc = RTCrPkcs7SimpleSignSignedData(RTCRPKCS7SIGN_SD_F_DEATCHED | RTCRPKCS7SIGN_SD_F_NO_SMIME_CAP,2468 pCertificate, hPrivateKey, pvManifest, (size_t)cbManifest, enmDigestType,2469 hIntermediateCerts, NULL /*pAdditionalAuthenticatedAttribs*/,2470 NULL /*pvResult*/, &cbResult, RTErrInfoInitStatic(pErrInfo));2471 if ( rc == VERR_BUFFER_OVERFLOW)2468 vrc = RTCrPkcs7SimpleSignSignedData(RTCRPKCS7SIGN_SD_F_DEATCHED | RTCRPKCS7SIGN_SD_F_NO_SMIME_CAP, 2469 pCertificate, hPrivateKey, pvManifest, (size_t)cbManifest, enmDigestType, 2470 hIntermediateCerts, NULL /*pAdditionalAuthenticatedAttribs*/, 2471 NULL /*pvResult*/, &cbResult, RTErrInfoInitStatic(pErrInfo)); 2472 if (vrc == VERR_BUFFER_OVERFLOW) 2472 2473 { 2473 2474 /* … … 2477 2478 if (pvResult) 2478 2479 { 2479 rc = RTCrPkcs7SimpleSignSignedData(RTCRPKCS7SIGN_SD_F_DEATCHED | RTCRPKCS7SIGN_SD_F_NO_SMIME_CAP,2480 pCertificate, hPrivateKey, pvManifest, (size_t)cbManifest, enmDigestType,2481 hIntermediateCerts, NULL /*pAdditionalAuthenticatedAttribs*/,2482 pvResult, &cbResult, RTErrInfoInitStatic(pErrInfo));2483 if (RT_SUCCESS( rc))2480 vrc = RTCrPkcs7SimpleSignSignedData(RTCRPKCS7SIGN_SD_F_DEATCHED | RTCRPKCS7SIGN_SD_F_NO_SMIME_CAP, 2481 pCertificate, hPrivateKey, pvManifest, (size_t)cbManifest, enmDigestType, 2482 hIntermediateCerts, NULL /*pAdditionalAuthenticatedAttribs*/, 2483 pvResult, &cbResult, RTErrInfoInitStatic(pErrInfo)); 2484 if (RT_SUCCESS(vrc)) 2484 2485 { 2485 2486 /* 2486 2487 * Add it to the signature file in PEM format. 2487 2488 */ 2488 rc = (int)RTCrPemWriteBlobToVfsFile(hVfsFileSignature, pvResult, cbResult, "CMS");2489 if (RT_SUCCESS( rc))2489 vrc = (int)RTCrPemWriteBlobToVfsFile(hVfsFileSignature, pvResult, cbResult, "CMS"); 2490 if (RT_SUCCESS(vrc)) 2490 2491 { 2491 2492 if (iVerbosity > 1) … … 2498 2499 * Try decode and verify the signature. 2499 2500 */ 2500 rc = doCheckPkcs7Signature(pvResult, cbResult, pCertificate, hIntermediateCerts,2501 pvManifest, (size_t)cbManifest, iVerbosity, pErrInfo);2501 vrc = doCheckPkcs7Signature(pvResult, cbResult, pCertificate, hIntermediateCerts, 2502 pvManifest, (size_t)cbManifest, iVerbosity, pErrInfo); 2502 2503 } 2503 2504 else 2504 RTMsgError(Appliance::tr("RTCrPemWriteBlobToVfsFile failed: %Rrc"), rc);2505 RTMsgError(Appliance::tr("RTCrPemWriteBlobToVfsFile failed: %Rrc"), vrc); 2505 2506 } 2506 2507 RTMemFree(pvResult); 2507 2508 } 2508 2509 else 2509 rc = RTMsgErrorRc(VERR_NO_MEMORY, Appliance::tr("Out of memory!"));2510 vrc = RTMsgErrorRc(VERR_NO_MEMORY, Appliance::tr("Out of memory!")); 2510 2511 } 2511 2512 else 2512 RTMsgError(Appliance::tr("RTCrPkcs7SimpleSignSignedData failed: %Rrc%#RTeim"), rc, &pErrInfo->Core);2513 RTMsgError(Appliance::tr("RTCrPkcs7SimpleSignSignedData failed: %Rrc%#RTeim"), vrc, &pErrInfo->Core); 2513 2514 } 2514 2515 } 2515 2516 else 2516 RTMsgError(Appliance::tr("RTVfsFileReadAt failed: %Rrc"), rc);2517 RTMsgError(Appliance::tr("RTVfsFileReadAt failed: %Rrc"), vrc); 2517 2518 RTMemFree(pvManifest); 2518 return rc;2519 return vrc; 2519 2520 } 2520 2521 … … 2574 2575 */ 2575 2576 RTCRDIGEST hDigest = NIL_RTCRDIGEST; 2576 int rc = RTCrDigestCreateByType(&hDigest, enmDigestType);2577 if (RT_FAILURE( rc))2578 return RTMsgErrorRc( rc, Appliance::tr("Failed to create digest for %s: %Rrc"), RTCrDigestTypeToName(enmDigestType),rc);2579 2580 rc = RTCrDigestUpdateFromVfsFile(hDigest, hVfsFileManifest, true /*fRewindFile*/);2581 if (RT_SUCCESS( rc))2582 rc = RTCrDigestFinal(hDigest, NULL, 0);2583 if (RT_SUCCESS( rc))2577 int vrc = RTCrDigestCreateByType(&hDigest, enmDigestType); 2578 if (RT_FAILURE(vrc)) 2579 return RTMsgErrorRc(vrc, Appliance::tr("Failed to create digest for %s: %Rrc"), RTCrDigestTypeToName(enmDigestType), vrc); 2580 2581 vrc = RTCrDigestUpdateFromVfsFile(hDigest, hVfsFileManifest, true /*fRewindFile*/); 2582 if (RT_SUCCESS(vrc)) 2583 vrc = RTCrDigestFinal(hDigest, NULL, 0); 2584 if (RT_SUCCESS(vrc)) 2584 2585 { 2585 2586 /* … … 2590 2591 PCRTASN1DYNTYPE const pAlgoParams = &pCertificate->TbsCertificate.SubjectPublicKeyInfo.Algorithm.Parameters; 2591 2592 size_t cbSignature = 0; 2592 rc = RTCrPkixPubKeySignDigest(pAlgorithm, hPrivateKey, pAlgoParams, hDigest, 0 /*fFlags*/,2593 NULL /*pvSignature*/, &cbSignature, RTErrInfoInitStatic(pErrInfo));2594 if ( rc == VERR_BUFFER_OVERFLOW)2593 vrc = RTCrPkixPubKeySignDigest(pAlgorithm, hPrivateKey, pAlgoParams, hDigest, 0 /*fFlags*/, 2594 NULL /*pvSignature*/, &cbSignature, RTErrInfoInitStatic(pErrInfo)); 2595 if (vrc == VERR_BUFFER_OVERFLOW) 2595 2596 { 2596 2597 void *pvSignature = RTMemAllocZ(cbSignature); 2597 2598 if (pvSignature) 2598 2599 { 2599 rc = RTCrPkixPubKeySignDigest(pAlgorithm, hPrivateKey, pAlgoParams, hDigest, 0,2600 pvSignature, &cbSignature, RTErrInfoInitStatic(pErrInfo));2601 if (RT_SUCCESS( rc))2600 vrc = RTCrPkixPubKeySignDigest(pAlgorithm, hPrivateKey, pAlgoParams, hDigest, 0, 2601 pvSignature, &cbSignature, RTErrInfoInitStatic(pErrInfo)); 2602 if (RT_SUCCESS(vrc)) 2602 2603 { 2603 2604 if (iVerbosity > 1) … … 2609 2610 * been given the right private key. 2610 2611 */ 2611 rc = RTCrPkixPubKeyVerifySignedDigestByCertPubKeyInfo(&pCertificate->TbsCertificate.SubjectPublicKeyInfo,2612 pvSignature, cbSignature, hDigest,2613 RTErrInfoInitStatic(pErrInfo));2614 if (RT_SUCCESS( rc))2612 vrc = RTCrPkixPubKeyVerifySignedDigestByCertPubKeyInfo(&pCertificate->TbsCertificate.SubjectPublicKeyInfo, 2613 pvSignature, cbSignature, hDigest, 2614 RTErrInfoInitStatic(pErrInfo)); 2615 if (RT_SUCCESS(vrc)) 2615 2616 { 2616 2617 if (iVerbosity > 2) … … 2621 2622 */ 2622 2623 RTVFSFILE hVfsFileSignature; 2623 rc = RTVfsMemFileCreate(NIL_RTVFSIOSTREAM, _8K, &hVfsFileSignature);2624 if (RT_SUCCESS( rc))2624 vrc = RTVfsMemFileCreate(NIL_RTVFSIOSTREAM, _8K, &hVfsFileSignature); 2625 if (RT_SUCCESS(vrc)) 2625 2626 { 2626 rc = (int)RTVfsFilePrintf(hVfsFileSignature, "%s(%s) = %#.*Rhxs\n\n",2627 pszDigestType, pszManifestName, cbSignature, pvSignature);2628 if (RT_SUCCESS( rc))2627 vrc = (int)RTVfsFilePrintf(hVfsFileSignature, "%s(%s) = %#.*Rhxs\n\n", 2628 pszDigestType, pszManifestName, cbSignature, pvSignature); 2629 if (RT_SUCCESS(vrc)) 2629 2630 { 2630 rc = (int)RTCrX509Certificate_WriteToVfsFile(hVfsFileSignature, pCertificate,2631 RTErrInfoInitStatic(pErrInfo));2632 if (RT_SUCCESS( rc))2631 vrc = (int)RTCrX509Certificate_WriteToVfsFile(hVfsFileSignature, pCertificate, 2632 RTErrInfoInitStatic(pErrInfo)); 2633 if (RT_SUCCESS(vrc)) 2633 2634 { 2634 2635 if (fPkcs7) 2635 rc = doAddPkcs7Signature(pCertificate, hPrivateKey, enmPkcs7DigestType,2636 cIntermediateCerts, papszIntermediateCerts, hVfsFileManifest,2637 iVerbosity, pErrInfo, hVfsFileSignature);2638 if (RT_SUCCESS( rc))2636 vrc = doAddPkcs7Signature(pCertificate, hPrivateKey, enmPkcs7DigestType, 2637 cIntermediateCerts, papszIntermediateCerts, hVfsFileManifest, 2638 iVerbosity, pErrInfo, hVfsFileSignature); 2639 if (RT_SUCCESS(vrc)) 2639 2640 { 2640 2641 /* … … 2647 2648 else 2648 2649 RTMsgError(Appliance::tr("Failed to write certificate to signature file: %Rrc%#RTeim"), 2649 rc, &pErrInfo->Core);2650 vrc, &pErrInfo->Core); 2650 2651 } 2651 2652 else 2652 RTMsgError(Appliance::tr("Failed to produce signature file: %Rrc"), rc);2653 RTMsgError(Appliance::tr("Failed to produce signature file: %Rrc"), vrc); 2653 2654 RTVfsFileRelease(hVfsFileSignature); 2654 2655 } 2655 2656 else 2656 RTMsgError(Appliance::tr("RTVfsMemFileCreate failed: %Rrc"), rc);2657 RTMsgError(Appliance::tr("RTVfsMemFileCreate failed: %Rrc"), vrc); 2657 2658 } 2658 2659 else 2659 2660 RTMsgError(Appliance::tr("Encountered a problem when validating the signature we just created: %Rrc%#RTeim\n" 2660 2661 "Please make sure the certificate and private key matches."), 2661 rc, &pErrInfo->Core);2662 vrc, &pErrInfo->Core); 2662 2663 } 2663 2664 else 2664 RTMsgError(Appliance::tr("2nd RTCrPkixPubKeySignDigest call failed: %Rrc%#RTeim"), rc, pErrInfo->Core);2665 RTMsgError(Appliance::tr("2nd RTCrPkixPubKeySignDigest call failed: %Rrc%#RTeim"), vrc, pErrInfo->Core); 2665 2666 RTMemFree(pvSignature); 2666 2667 } 2667 2668 else 2668 rc = RTMsgErrorRc(VERR_NO_MEMORY, Appliance::tr("Out of memory!"));2669 vrc = RTMsgErrorRc(VERR_NO_MEMORY, Appliance::tr("Out of memory!")); 2669 2670 } 2670 2671 else 2671 RTMsgError(Appliance::tr("RTCrPkixPubKeySignDigest failed: %Rrc%#RTeim"), rc, pErrInfo->Core);2672 RTMsgError(Appliance::tr("RTCrPkixPubKeySignDigest failed: %Rrc%#RTeim"), vrc, pErrInfo->Core); 2672 2673 } 2673 2674 else 2674 RTMsgError(Appliance::tr("Failed to create digest %s: %Rrc"), RTCrDigestTypeToName(enmDigestType), rc);2675 RTMsgError(Appliance::tr("Failed to create digest %s: %Rrc"), RTCrDigestTypeToName(enmDigestType), vrc); 2675 2676 RTCrDigestRelease(hDigest); 2676 return rc;2677 return vrc; 2677 2678 } 2678 2679 … … 2705 2706 2706 2707 RTGETOPTSTATE GetState; 2707 int rc = RTGetOptInit(&GetState, arg->argc, arg->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0);2708 AssertRCReturn( rc, RTEXITCODE_FAILURE);2708 int vrc = RTGetOptInit(&GetState, arg->argc, arg->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0); 2709 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 2709 2710 2710 2711 const char *pszOva = NULL; … … 2831 2832 RTVFSFILE hVfsFileManifest = NIL_RTVFSFILE; 2832 2833 Utf8Str strManifestName; 2833 rc = openOvaAndGetManifestAndOldSignature(pszOva, iVerbosity, fReSign,2834 &hVfsFssOva, &strManifestName, &hVfsFileManifest, &hVfsOldSignature);2835 if (RT_SUCCESS( rc))2834 vrc = openOvaAndGetManifestAndOldSignature(pszOva, iVerbosity, fReSign, 2835 &hVfsFssOva, &strManifestName, &hVfsFileManifest, &hVfsOldSignature); 2836 if (RT_SUCCESS(vrc)) 2836 2837 { 2837 2838 /* … … 2840 2841 RTERRINFOSTATIC ErrInfo; 2841 2842 RTCRX509CERTIFICATE Certificate; 2842 rc = RTCrX509Certificate_ReadFromFile(&Certificate, pszCertificate, 0, &g_RTAsn1DefaultAllocator,2843 RTErrInfoInitStatic(&ErrInfo));2844 if (RT_FAILURE( rc))2843 vrc = RTCrX509Certificate_ReadFromFile(&Certificate, pszCertificate, 0, &g_RTAsn1DefaultAllocator, 2844 RTErrInfoInitStatic(&ErrInfo)); 2845 if (RT_FAILURE(vrc)) 2845 2846 return RTMsgErrorExitFailure(Appliance::tr("Error reading certificate from '%s': %Rrc%#RTeim"), 2846 pszCertificate, rc, &ErrInfo.Core);2847 pszCertificate, vrc, &ErrInfo.Core); 2847 2848 2848 2849 RTCRKEY hPrivateKey = NIL_RTCRKEY; 2849 rc = RTCrKeyCreateFromFile(&hPrivateKey, 0 /*fFlags*/, pszPrivateKey, strPrivateKeyPassword.c_str(),2850 RTErrInfoInitStatic(&ErrInfo));2851 if (RT_SUCCESS( rc))2850 vrc = RTCrKeyCreateFromFile(&hPrivateKey, 0 /*fFlags*/, pszPrivateKey, strPrivateKeyPassword.c_str(), 2851 RTErrInfoInitStatic(&ErrInfo)); 2852 if (RT_SUCCESS(vrc)) 2852 2853 { 2853 2854 if (iVerbosity > 1) … … 2858 2859 */ 2859 2860 RTVFSFILE hVfsFileSignature = NIL_RTVFSFILE; 2860 rc = doTheOvaSigning(&Certificate, hPrivateKey, enmDigestType, strManifestName.c_str(), hVfsFileManifest,2861 fPkcs7, cIntermediateCerts, apszIntermediateCerts, iVerbosity, &ErrInfo, &hVfsFileSignature);2861 vrc = doTheOvaSigning(&Certificate, hPrivateKey, enmDigestType, strManifestName.c_str(), hVfsFileManifest, 2862 fPkcs7, cIntermediateCerts, apszIntermediateCerts, iVerbosity, &ErrInfo, &hVfsFileSignature); 2862 2863 2863 2864 /* 2864 2865 * Construct the signature filename: 2865 2866 */ 2866 if (RT_SUCCESS( rc))2867 if (RT_SUCCESS(vrc)) 2867 2868 { 2868 2869 Utf8Str strSignatureName; 2869 rc = strSignatureName.assignNoThrow(strManifestName);2870 if (RT_SUCCESS( rc))2871 rc = strSignatureName.stripSuffix().appendNoThrow(".cert");2872 if (RT_SUCCESS( rc) && !fDryRun)2870 vrc = strSignatureName.assignNoThrow(strManifestName); 2871 if (RT_SUCCESS(vrc)) 2872 vrc = strSignatureName.stripSuffix().appendNoThrow(".cert"); 2873 if (RT_SUCCESS(vrc) && !fDryRun) 2873 2874 { 2874 2875 /* 2875 2876 * Update the OVA. 2876 2877 */ 2877 rc = updateTheOvaSignature(hVfsFssOva, pszOva, strSignatureName.c_str(),2878 hVfsFileSignature, hVfsOldSignature, iVerbosity);2879 if (RT_SUCCESS( rc) && iVerbosity > 0)2878 vrc = updateTheOvaSignature(hVfsFssOva, pszOva, strSignatureName.c_str(), 2879 hVfsFileSignature, hVfsOldSignature, iVerbosity); 2880 if (RT_SUCCESS(vrc) && iVerbosity > 0) 2880 2881 RTMsgInfo(Appliance::tr("Successfully signed '%s'."), pszOva); 2881 2882 } … … 2884 2885 } 2885 2886 else 2886 RTPrintf(Appliance::tr("Error reading the private key from %s: %Rrc%#RTeim"), pszPrivateKey, rc, &ErrInfo.Core);2887 RTPrintf(Appliance::tr("Error reading the private key from %s: %Rrc%#RTeim"), pszPrivateKey, vrc, &ErrInfo.Core); 2887 2888 RTCrX509Certificate_Delete(&Certificate); 2888 2889 } … … 2892 2893 RTVfsFsStrmRelease(hVfsFssOva); 2893 2894 2894 return RT_SUCCESS( rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;2895 return RT_SUCCESS(vrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 2895 2896 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageBandwidthControl.cpp
r98103 r98298 66 66 int iMultiplier = _1M; 67 67 char *pszNext = NULL; 68 int rc = RTStrToInt64Ex(pcszLimit, &pszNext, 10, pLimit);69 70 switch ( rc)68 int vrc = RTStrToInt64Ex(pcszLimit, &pszNext, 10, pLimit); 69 70 switch (vrc) 71 71 { 72 72 case VINF_SUCCESS: -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloudMachine.cpp
r98103 r98298 120 120 { 121 121 CMachineHandlerArg handlerArg(*a); 122 int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName);123 if (RT_FAILURE( rc))122 int vrc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName); 123 if (RT_FAILURE(vrc)) 124 124 return RTEXITCODE_FAILURE; 125 125 … … 245 245 if (aProfiles.size() > 1) 246 246 { 247 RTMsgError(CloudMachine::tr("cloud: multiple profiles exist," 248 " '--profile' option is required")); 247 RTMsgError(CloudMachine::tr("cloud: multiple profiles exist, '--profile' option is required")); 249 248 return VERR_MISSING; 250 249 } … … 261 260 const char *pcszProfileName) 262 261 { 263 HRESULT hrc;264 int rc;265 266 262 ComPtr<ICloudProvider> pProvider; 267 rc = selectCloudProvider(pProvider, a.virtualBox, pcszProviderName);268 if (RT_FAILURE( rc))269 return rc;263 int vrc = selectCloudProvider(pProvider, a.virtualBox, pcszProviderName); 264 if (RT_FAILURE(vrc)) 265 return vrc; 270 266 271 267 ComPtr<ICloudProfile> pProfile; 272 rc = selectCloudProfile(pProfile, pProvider, pcszProfileName);273 if (RT_FAILURE( rc))274 return rc;268 vrc = selectCloudProfile(pProfile, pProvider, pcszProfileName); 269 if (RT_FAILURE(vrc)) 270 return vrc; 275 271 276 272 ComPtr<ICloudClient> pCloudClient; 277 CHECK_ERROR2_RET(hrc, pProfile, 278 CreateCloudClient(pCloudClient.asOutParam()), 279 VERR_GENERAL_FAILURE); 273 CHECK_ERROR2I_RET(pProfile, CreateCloudClient(pCloudClient.asOutParam()), VERR_GENERAL_FAILURE); 280 274 281 275 a.pClient = pCloudClient; … … 358 352 359 353 if (pMachineFound.isNull()) 360 {361 354 pMachineFound = pMachine; 362 }363 355 else 364 356 { … … 398 390 399 391 RTUUID Uuid; 400 int rc = RTUuidFromStr(&Uuid, a->pcszSpec);401 if (RT_SUCCESS( rc))392 int vrc = RTUuidFromStr(&Uuid, a->pcszSpec); 393 if (RT_SUCCESS(vrc)) 402 394 hrc = getMachineById(a); 403 395 else … … 449 441 int ch, const RTGETOPTUNION &Val) 450 442 { 451 int rc;443 int vrc; 452 444 453 445 switch (ch) … … 472 464 473 465 RTUUID Uuid; 474 rc = RTUuidFromStr(&Uuid, pcszId);475 if (RT_FAILURE( rc))466 vrc = RTUuidFromStr(&Uuid, pcszId); 467 if (RT_FAILURE(vrc)) 476 468 { 477 469 RTMsgError(CloudMachine::tr("not a valid uuid: %s"), pcszId); … … 611 603 handleCloudMachineImpl(CMachineHandlerArg *a, int iFirst) 612 604 { 613 int rc;614 615 605 enum 616 606 { … … 643 633 644 634 RTGETOPTSTATE OptState; 645 rc = RTGetOptInit(&OptState, a->argc, a->argv, 646 s_aOptions, RT_ELEMENTS(s_aOptions), 647 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 648 AssertRCReturn(rc, RTMsgErrorExit(RTEXITCODE_INIT, 649 CloudMachine::tr("cloud machine: RTGetOptInit: %Rra"), rc)); 635 int vrc = RTGetOptInit(&OptState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 636 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 637 AssertRCReturn(vrc, RTMsgErrorExit(RTEXITCODE_INIT, CloudMachine::tr("cloud machine: RTGetOptInit: %Rra"), vrc)); 650 638 651 639 int ch; … … 668 656 * Also handles --help. 669 657 */ 670 rc = checkMachineSpecArgument(a, ch, Val);671 if ( rc == VINF_SUCCESS)658 vrc = checkMachineSpecArgument(a, ch, Val); 659 if (vrc == VINF_SUCCESS) 672 660 continue; 673 else if (rc == VINF_CALLBACK_RETURN)661 if (vrc == VINF_CALLBACK_RETURN) 674 662 return RTEXITCODE_SUCCESS; 675 else if (rc == VERR_PARSE_ERROR)663 if (vrc == VERR_PARSE_ERROR) 676 664 return RTEXITCODE_SYNTAX; 677 665 … … 731 719 { 732 720 CMachineHandlerArg handlerArg(*a); 733 int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName);734 if (RT_FAILURE( rc))721 int vrc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName); 722 if (RT_FAILURE(vrc)) 735 723 return RTEXITCODE_FAILURE; 736 724 … … 746 734 listCloudMachinesImpl(CMachineHandlerArg *a, int iFirst) 747 735 { 748 HRESULT hrc;749 int rc;750 751 736 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_LIST); 752 737 static const RTGETOPTDEF s_aOptions[] = … … 769 754 770 755 RTGETOPTSTATE OptState; 771 rc = RTGetOptInit(&OptState, a->argc, a->argv, 772 s_aOptions, RT_ELEMENTS(s_aOptions), 773 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 774 AssertRCReturn(rc, RTMsgErrorExit(RTEXITCODE_INIT, 775 CloudMachine::tr("cloud machine list: RTGetOptInit: %Rra"), rc)); 756 int vrc = RTGetOptInit(&OptState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 757 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 758 AssertRCReturn(vrc, RTMsgErrorExit(RTEXITCODE_INIT, CloudMachine::tr("cloud machine list: RTGetOptInit: %Rra"), vrc)); 776 759 777 760 int ch; … … 805 788 806 789 com::SafeIfaceArray<ICloudMachine> aMachines; 807 hrc = getMachineList(aMachines, a->pClient);790 HRESULT hrc = getMachineList(aMachines, a->pClient); 808 791 if (FAILED(hrc)) 809 792 return RTEXITCODE_FAILURE; … … 897 880 { 898 881 CMachineHandlerArg handlerArg(*a); 899 int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName);900 if (RT_FAILURE( rc))882 int vrc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName); 883 if (RT_FAILURE(vrc)) 901 884 return RTEXITCODE_FAILURE; 902 885 … … 911 894 handleCloudMachineInfo(CMachineHandlerArg *a, int iFirst) 912 895 { 913 HRESULT hrc;914 int rc;915 916 896 enum 917 897 { … … 929 909 930 910 RTGETOPTSTATE OptState; 931 rc = RTGetOptInit(&OptState, a->argc, a->argv, 932 s_aOptions, RT_ELEMENTS(s_aOptions), 933 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 934 AssertRCReturn(rc, RTMsgErrorExit(RTEXITCODE_INIT, 935 "RTGetOptInit: %Rra", rc)); 911 int vrc = RTGetOptInit(&OptState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 912 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 913 AssertRCReturn(vrc, RTMsgErrorExit(RTEXITCODE_INIT, "RTGetOptInit: %Rra", vrc)); 936 914 937 915 int ch; … … 939 917 while ((ch = RTGetOpt(&OptState, &Val)) != 0) 940 918 { 941 rc = checkMachineSpecArgument(a, ch, Val);942 if ( rc == VINF_SUCCESS)919 vrc = checkMachineSpecArgument(a, ch, Val); 920 if (vrc == VINF_SUCCESS) 943 921 continue; 944 else if (rc == VINF_CALLBACK_RETURN)922 if (vrc == VINF_CALLBACK_RETURN) 945 923 return RTEXITCODE_SUCCESS; 946 else if (rc == VERR_PARSE_ERROR)924 if (vrc == VERR_PARSE_ERROR) 947 925 return RTEXITCODE_SYNTAX; 948 926 … … 958 936 } 959 937 960 hrc = getMachineBySpec(a);938 HRESULT hrc = getMachineBySpec(a); 961 939 if (FAILED(hrc)) 962 940 return RTEXITCODE_FAILURE; … … 1269 1247 getMachineFromArgs(CMachineHandlerArg *a, int iFirst) 1270 1248 { 1271 HRESULT hrc;1272 int rc;1273 1274 1249 static const RTGETOPTDEF s_aOptions[] = 1275 1250 { … … 1279 1254 1280 1255 RTGETOPTSTATE OptState; 1281 rc = RTGetOptInit(&OptState, a->argc, a->argv, 1282 s_aOptions, RT_ELEMENTS(s_aOptions), 1283 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 1284 AssertRCStmt(rc, 1285 return RTMsgErrorExit(RTEXITCODE_INIT, /* internal error */ 1286 "RTGetOptInit: %Rra", rc)); 1256 int vrc = RTGetOptInit(&OptState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1257 iFirst, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 1258 AssertRCReturn(vrc, RTMsgErrorExit(RTEXITCODE_INIT, /* internal error */ "RTGetOptInit: %Rra", vrc)); 1287 1259 1288 1260 int ch; … … 1290 1262 while ((ch = RTGetOpt(&OptState, &Val)) != 0) 1291 1263 { 1292 rc = checkMachineSpecArgument(a, ch, Val);1293 if ( rc == VINF_SUCCESS)1264 vrc = checkMachineSpecArgument(a, ch, Val); 1265 if (vrc == VINF_SUCCESS) 1294 1266 continue; 1295 else if (rc == VINF_CALLBACK_RETURN)1267 if (vrc == VINF_CALLBACK_RETURN) 1296 1268 return RTEXITCODE_SUCCESS; 1297 else if (rc == VERR_PARSE_ERROR)1269 if (vrc == VERR_PARSE_ERROR) 1298 1270 return RTEXITCODE_SYNTAX; 1299 1271 … … 1306 1278 } 1307 1279 1308 hrc = getMachineBySpec(a);1280 HRESULT hrc = getMachineBySpec(a); 1309 1281 if (FAILED(hrc)) 1310 1282 return RTEXITCODE_FAILURE; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
r98103 r98298 67 67 uint32_t u32; 68 68 char *pszNext; 69 int rc = RTStrToUInt32Ex(psz, &pszNext, 10, &u32);70 if ( RT_SUCCESS( rc)69 int vrc = RTStrToUInt32Ex(psz, &pszNext, 10, &u32); 70 if ( RT_SUCCESS(vrc) 71 71 && *pszNext == '\0' 72 72 && u32 >= 1 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDebugVM.cpp
r98103 r98298 75 75 { "--cpu", 'c', RTGETOPT_REQ_UINT32 }, 76 76 }; 77 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);78 AssertRCReturn( rc, RTEXITCODE_FAILURE);79 80 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)81 { 82 switch ( rc)77 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST); 78 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 79 80 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 81 { 82 switch (vrc) 83 83 { 84 84 case 'c': … … 118 118 119 119 default: 120 return errorGetOpt( rc, &ValueUnion);120 return errorGetOpt(vrc, &ValueUnion); 121 121 } 122 122 } … … 143 143 RTGETOPTSTATE GetState; 144 144 RTGETOPTUNION ValueUnion; 145 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, NULL, 0, 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);146 AssertRCReturn( rc, RTEXITCODE_FAILURE);147 148 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)149 { 150 switch ( rc)145 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, NULL, 0, 2, RTGETOPTINIT_FLAGS_OPTS_FIRST); 146 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 147 148 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 149 { 150 switch (vrc) 151 151 { 152 152 case VINF_GETOPT_NOT_OPTION: … … 159 159 break; 160 160 default: 161 return errorGetOpt( rc, &ValueUnion);161 return errorGetOpt(vrc, &ValueUnion); 162 162 } 163 163 } … … 223 223 { "--release", DEBUGVM_LOG_RELEASE, RTGETOPT_REQ_NOTHING } 224 224 }; 225 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2,226 /*227 * Note: RTGETOPTINIT_FLAGS_NO_STD_OPTS is needed to not get into an infinite hang in the following228 * while-loop when processing log groups starting with "h",229 * e.g. "VBoxManage debugvm <VM Name> log --debug -hex".230 */225 /* 226 * Note: RTGETOPTINIT_FLAGS_NO_STD_OPTS is needed to not get into an infinite hang in the following 227 * while-loop when processing log groups starting with "h", 228 * e.g. "VBoxManage debugvm <VM Name> log --debug -hex". 229 */ 230 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 231 231 RTGETOPTINIT_FLAGS_OPTS_FIRST | RTGETOPTINIT_FLAGS_NO_STD_OPTS); 232 AssertRCReturn( rc, RTEXITCODE_FAILURE);233 234 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)235 { 236 switch ( rc)232 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 233 234 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 235 { 236 switch (vrc) 237 237 { 238 238 case DEBUGVM_LOG_RELEASE: … … 302 302 { "--compression", 'c', RTGETOPT_REQ_STRING } 303 303 }; 304 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/);305 AssertRCReturn( rc, RTEXITCODE_FAILURE);306 307 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)308 { 309 switch ( rc)304 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/); 305 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 306 307 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 308 { 309 switch (vrc) 310 310 { 311 311 case 'c': … … 320 320 break; 321 321 default: 322 return errorGetOpt( rc, &ValueUnion);322 return errorGetOpt(vrc, &ValueUnion); 323 323 } 324 324 } … … 331 331 */ 332 332 char szAbsFilename[RTPATH_MAX]; 333 rc = RTPathAbs(pszFilename, szAbsFilename, sizeof(szAbsFilename));334 if (RT_FAILURE( rc))335 return RTMsgErrorExit(RTEXITCODE_FAILURE, DebugVM::tr("RTPathAbs failed on '%s': %Rrc"), pszFilename, rc);333 vrc = RTPathAbs(pszFilename, szAbsFilename, sizeof(szAbsFilename)); 334 if (RT_FAILURE(vrc)) 335 return RTMsgErrorExit(RTEXITCODE_FAILURE, DebugVM::tr("RTPathAbs failed on '%s': %Rrc"), pszFilename, vrc); 336 336 337 337 com::Bstr bstrFilename(szAbsFilename); … … 403 403 { "--lines", 'n', RTGETOPT_REQ_UINT32 }, 404 404 }; 405 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);406 AssertRCReturn( rc, RTEXITCODE_FAILURE);407 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)408 switch ( rc)405 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST); 406 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 407 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 408 switch (vrc) 409 409 { 410 410 case 'n': uMaxMessages = ValueUnion.u32; break; 411 default: return errorGetOpt( rc, &ValueUnion);411 default: return errorGetOpt(vrc, &ValueUnion); 412 412 } 413 413 … … 443 443 { "--cpu", 'c', RTGETOPT_REQ_UINT32 }, 444 444 }; 445 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);446 AssertRCReturn( rc, RTEXITCODE_FAILURE);447 448 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)449 { 450 switch ( rc)445 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST); 446 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 447 448 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 449 { 450 switch (vrc) 451 451 { 452 452 case 'c': … … 477 477 478 478 default: 479 return errorGetOpt( rc, &ValueUnion);479 return errorGetOpt(vrc, &ValueUnion); 480 480 } 481 481 } … … 602 602 { "--cmd-set", 's', RTGETOPT_REQ_NOTHING }, 603 603 }; 604 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/);605 AssertRCReturn( rc, RTEXITCODE_FAILURE);606 607 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)608 { 609 switch ( rc)604 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/); 605 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 606 607 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 608 { 609 switch (vrc) 610 610 { 611 611 case 'H': … … 646 646 647 647 default: 648 return errorGetOpt( rc, &ValueUnion);648 return errorGetOpt(vrc, &ValueUnion); 649 649 } 650 650 } … … 672 672 { "--cpu", 'c', RTGETOPT_REQ_UINT32 }, 673 673 }; 674 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);675 AssertRCReturn( rc, RTEXITCODE_FAILURE);676 677 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)678 { 679 switch ( rc)674 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST); 675 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 676 677 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 678 { 679 switch (vrc) 680 680 { 681 681 case 'c': … … 684 684 685 685 default: 686 return errorGetOpt( rc, &ValueUnion);686 return errorGetOpt(vrc, &ValueUnion); 687 687 } 688 688 } … … 747 747 { "--reset", 'r', RTGETOPT_REQ_NOTHING }, 748 748 }; 749 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/);750 AssertRCReturn( rc, RTEXITCODE_FAILURE);751 752 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)753 { 754 switch ( rc)749 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/); 750 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 751 752 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 753 { 754 switch (vrc) 755 755 { 756 756 case 'd': … … 769 769 770 770 default: 771 return errorGetOpt( rc, &ValueUnion);771 return errorGetOpt(vrc, &ValueUnion); 772 772 } 773 773 } … … 821 821 { "--sample-time-us", 't', RTGETOPT_REQ_UINT64 }, 822 822 }; 823 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/);824 AssertRCReturn( rc, RTEXITCODE_FAILURE);825 826 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)827 { 828 switch ( rc)823 int vrc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/); 824 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 825 826 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 827 { 828 switch (vrc) 829 829 { 830 830 case 'f': … … 839 839 840 840 default: 841 return errorGetOpt( rc, &ValueUnion);841 return errorGetOpt(vrc, &ValueUnion); 842 842 } 843 843 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r98103 r98298 68 68 69 69 70 static DECLCALLBACK(void) handleVDError(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)70 static DECLCALLBACK(void) handleVDError(void *pvUser, int vrc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) 71 71 { 72 72 RT_NOREF(pvUser); 73 73 RTMsgErrorV(pszFormat, va); 74 RTMsgError(Disk::tr("Error code %Rrc at %s(%u) in function %s"), rc, RT_SRC_POS_ARGS);74 RTMsgError(Disk::tr("Error code %Rrc at %s(%u) in function %s"), vrc, RT_SRC_POS_ARGS); 75 75 } 76 76 77 77 static int parseMediumVariant(const char *psz, MediumVariant_T *pMediumVariant) 78 78 { 79 int rc = VINF_SUCCESS;79 int vrc = VINF_SUCCESS; 80 80 unsigned uMediumVariant = (unsigned)(*pMediumVariant); 81 while (psz && *psz && RT_SUCCESS( rc))81 while (psz && *psz && RT_SUCCESS(vrc)) 82 82 { 83 83 size_t len; … … 111 111 uMediumVariant |= MediumVariant_VmdkRawDisk; 112 112 else 113 rc = VERR_PARSE_ERROR;113 vrc = VERR_PARSE_ERROR; 114 114 } 115 115 if (pszComma) … … 119 119 } 120 120 121 if (RT_SUCCESS( rc))121 if (RT_SUCCESS(vrc)) 122 122 *pMediumVariant = (MediumVariant_T)uMediumVariant; 123 return rc;123 return vrc; 124 124 } 125 125 126 126 int parseMediumType(const char *psz, MediumType_T *penmMediumType) 127 127 { 128 int rc = VINF_SUCCESS;128 int vrc = VINF_SUCCESS; 129 129 MediumType_T enmMediumType = MediumType_Normal; 130 130 if (!RTStrICmp(psz, "normal")) … … 141 141 enmMediumType = MediumType_MultiAttach; 142 142 else 143 rc = VERR_PARSE_ERROR;144 145 if (RT_SUCCESS( rc))143 vrc = VERR_PARSE_ERROR; 144 145 if (RT_SUCCESS(vrc)) 146 146 *penmMediumType = enmMediumType; 147 return rc;147 return vrc; 148 148 } 149 149 … … 151 151 int parseBool(const char *psz, bool *pb) 152 152 { 153 int rc = VINF_SUCCESS;153 int vrc = VINF_SUCCESS; 154 154 if ( !RTStrICmp(psz, "on") 155 155 || !RTStrICmp(psz, "yes") 156 156 || !RTStrICmp(psz, "true") 157 || !RTStr ICmp(psz, "1")157 || !RTStrCmp(psz, "1") 158 158 || !RTStrICmp(psz, "enable") 159 159 || !RTStrICmp(psz, "enabled")) 160 {161 160 *pb = true; 162 }163 161 else if ( !RTStrICmp(psz, "off") 164 162 || !RTStrICmp(psz, "no") 165 163 || !RTStrICmp(psz, "false") 166 || !RTStr ICmp(psz, "0")164 || !RTStrCmp(psz, "0") 167 165 || !RTStrICmp(psz, "disable") 168 166 || !RTStrICmp(psz, "disabled")) 169 {170 167 *pb = false; 171 }172 168 else 173 rc = VERR_PARSE_ERROR;174 175 return rc;169 vrc = VERR_PARSE_ERROR; 170 171 return vrc; 176 172 } 177 173 … … 1236 1232 RTEXITCODE handleConvertFromRaw(HandlerArg *a) 1237 1233 { 1238 int rc = VINF_SUCCESS;1239 1234 bool fReadFromStdIn = false; 1240 1235 const char *format = "VDI"; … … 1251 1246 RTGETOPTSTATE GetState; 1252 1247 // start at 0 because main() has hacked both the argc and argv given to us 1253 RTGetOptInit(&GetState, a->argc, a->argv, g_aConvertFromRawHardDiskOptions, RT_ELEMENTS(g_aConvertFromRawHardDiskOptions), 1254 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 1248 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, 1249 g_aConvertFromRawHardDiskOptions, RT_ELEMENTS(g_aConvertFromRawHardDiskOptions), 1250 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 1251 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 1255 1252 while ((c = RTGetOpt(&GetState, &ValueUnion))) 1256 1253 { … … 1269 1266 { 1270 1267 MediumVariant_T enmMediumVariant = MediumVariant_Standard; 1271 rc = parseMediumVariant(ValueUnion.psz, &enmMediumVariant);1272 if (RT_FAILURE( rc))1268 vrc = parseMediumVariant(ValueUnion.psz, &enmMediumVariant); 1269 if (RT_FAILURE(vrc)) 1273 1270 return errorArgument(Disk::tr("Invalid medium variant '%s'"), ValueUnion.psz); 1274 1271 /// @todo cleaner solution than assuming 1:1 mapping? … … 1307 1304 vdInterfaceError.pfnMessage = NULL; 1308 1305 1309 rc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR,1310 NULL, sizeof(VDINTERFACEERROR), &pVDIfs);1311 AssertRC( rc);1306 vrc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR, 1307 NULL, sizeof(VDINTERFACEERROR), &pVDIfs); 1308 AssertRC(vrc); 1312 1309 1313 1310 /* open raw image file. */ 1314 1311 RTFILE File; 1315 1312 if (fReadFromStdIn) 1316 rc = RTFileFromNative(&File, RTFILE_NATIVE_STDIN);1313 vrc = RTFileFromNative(&File, RTFILE_NATIVE_STDIN); 1317 1314 else 1318 rc = RTFileOpen(&File, srcfilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);1319 if (RT_FAILURE( rc))1320 { 1321 RTMsgError(Disk::tr("Cannot open file \"%s\": %Rrc"), srcfilename, rc);1315 vrc = RTFileOpen(&File, srcfilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 1316 if (RT_FAILURE(vrc)) 1317 { 1318 RTMsgError(Disk::tr("Cannot open file \"%s\": %Rrc"), srcfilename, vrc); 1322 1319 goto out; 1323 1320 } … … 1328 1325 cbFile = RTStrToUInt64(filesize); 1329 1326 else 1330 rc = RTFileQuerySize(File, &cbFile);1331 if (RT_FAILURE( rc))1332 { 1333 RTMsgError(Disk::tr("Cannot get image size for file \"%s\": %Rrc"), srcfilename, rc);1327 vrc = RTFileQuerySize(File, &cbFile); 1328 if (RT_FAILURE(vrc)) 1329 { 1330 RTMsgError(Disk::tr("Cannot get image size for file \"%s\": %Rrc"), srcfilename, vrc); 1334 1331 goto out; 1335 1332 } … … 1340 1337 char pszComment[256]; 1341 1338 RTStrPrintf(pszComment, sizeof(pszComment), Disk::tr("Converted image from %s"), srcfilename); 1342 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk);1343 if (RT_FAILURE( rc))1344 { 1345 RTMsgError(Disk::tr("Cannot create the virtual disk container: %Rrc"), rc);1339 vrc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); 1340 if (RT_FAILURE(vrc)) 1341 { 1342 RTMsgError(Disk::tr("Cannot create the virtual disk container: %Rrc"), vrc); 1346 1343 goto out; 1347 1344 } … … 1356 1353 LCHS.cHeads = 0; 1357 1354 LCHS.cSectors = 0; 1358 rc = VDCreateBase(pDisk, format, dstfilename, cbFile,1359 uImageFlags, pszComment, &PCHS, &LCHS, pUuid,1360 VD_OPEN_FLAGS_NORMAL, NULL, NULL);1361 if (RT_FAILURE( rc))1362 { 1363 RTMsgError(Disk::tr("Cannot create the disk image \"%s\": %Rrc"), dstfilename, rc);1355 vrc = VDCreateBase(pDisk, format, dstfilename, cbFile, 1356 uImageFlags, pszComment, &PCHS, &LCHS, pUuid, 1357 VD_OPEN_FLAGS_NORMAL, NULL, NULL); 1358 if (RT_FAILURE(vrc)) 1359 { 1360 RTMsgError(Disk::tr("Cannot create the disk image \"%s\": %Rrc"), dstfilename, vrc); 1364 1361 goto out; 1365 1362 } … … 1370 1367 if (!pvBuf) 1371 1368 { 1372 rc = VERR_NO_MEMORY;1373 RTMsgError(Disk::tr("Out of memory allocating buffers for image \"%s\": %Rrc"), dstfilename, rc);1369 vrc = VERR_NO_MEMORY; 1370 RTMsgError(Disk::tr("Out of memory allocating buffers for image \"%s\": %Rrc"), dstfilename, vrc); 1374 1371 goto out; 1375 1372 } … … 1384 1381 cbToRead = cbFile - offFile >= (uint64_t)cbBuffer ? 1385 1382 cbBuffer : (size_t)(cbFile - offFile); 1386 rc = RTFileRead(File, pvBuf, cbToRead, &cbRead);1387 if (RT_FAILURE( rc) || !cbRead)1383 vrc = RTFileRead(File, pvBuf, cbToRead, &cbRead); 1384 if (RT_FAILURE(vrc) || !cbRead) 1388 1385 break; 1389 rc = VDWrite(pDisk, offFile, pvBuf, cbRead);1390 if (RT_FAILURE( rc))1391 { 1392 RTMsgError(Disk::tr("Failed to write to disk image \"%s\": %Rrc"), dstfilename, rc);1386 vrc = VDWrite(pDisk, offFile, pvBuf, cbRead); 1387 if (RT_FAILURE(vrc)) 1388 { 1389 RTMsgError(Disk::tr("Failed to write to disk image \"%s\": %Rrc"), dstfilename, vrc); 1393 1390 goto out; 1394 1391 } … … 1400 1397 RTMemFree(pvBuf); 1401 1398 if (pDisk) 1402 VDClose(pDisk, RT_FAILURE( rc));1399 VDClose(pDisk, RT_FAILURE(vrc)); 1403 1400 if (File != NIL_RTFILE) 1404 1401 RTFileClose(File); 1405 1402 1406 return RT_SUCCESS( rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;1403 return RT_SUCCESS(vrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 1407 1404 } 1408 1405 … … 2318 2315 2319 2316 RTGETOPTSTATE GetState; 2320 int rc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0);2321 AssertRC (rc);2317 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0); 2318 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 2322 2319 RTGETOPTUNION ValueUnion; 2323 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)2324 { 2325 switch ( rc)2320 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 2321 { 2322 switch (vrc) 2326 2323 { 2327 2324 MEDIUMIOCOMMONOPT_CASES(pCommonOpts); … … 2332 2329 2333 2330 default: 2334 return errorGetOpt( rc, &ValueUnion);2331 return errorGetOpt(vrc, &ValueUnion); 2335 2332 } 2336 2333 } … … 2369 2366 2370 2367 RTGETOPTSTATE GetState; 2371 int rc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0);2372 AssertRC (rc);2368 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0); 2369 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 2373 2370 RTGETOPTUNION ValueUnion; 2374 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)2375 { 2376 switch ( rc)2371 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 2372 { 2373 switch (vrc) 2377 2374 { 2378 2375 MEDIUMIOCOMMONOPT_CASES(pCommonOpts); … … 2395 2392 2396 2393 default: 2397 return errorGetOpt( rc, &ValueUnion);2394 return errorGetOpt(vrc, &ValueUnion); 2398 2395 } 2399 2396 } … … 2413 2410 if (pszOutput && (pszOutput[0] != '-' || pszOutput[1] != '\0')) 2414 2411 { 2415 intvrc = RTStrmOpen(pszOutput, fHex ? "wt" : "wb", &pOut);2412 vrc = RTStrmOpen(pszOutput, fHex ? "wt" : "wb", &pOut); 2416 2413 if (RT_FAILURE(vrc)) 2417 2414 rcExit = RTMsgErrorExitFailure(Disk::tr("Error opening '%s' for writing: %Rrc"), pszOutput, vrc); … … 2471 2468 { 2472 2469 BYTE const *pbBuf = SafeArrayBuf.raw(); 2473 int vrc = VINF_SUCCESS;2474 2470 if (!fHex) 2475 2471 vrc = RTStrmWrite(pOut, pbBuf, cbReturned); … … 2477 2473 { 2478 2474 /* hexdump -C */ 2475 vrc = VINF_SUCCESS; 2479 2476 uint64_t offHex = off; 2480 2477 uint64_t const offHexEnd = off + cbReturned; … … 2561 2558 if (pOut != g_pStdOut) 2562 2559 { 2563 intvrc = RTStrmClose(pOut);2560 vrc = RTStrmClose(pOut); 2564 2561 if (RT_FAILURE(vrc)) 2565 2562 rcExit = RTMsgErrorExitFailure(Disk::tr("Error closing '%s': %Rrc"), pszOutput, vrc); … … 2592 2589 2593 2590 RTGETOPTSTATE GetState; 2594 int rc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0);2595 AssertRC (rc);2591 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0); 2592 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 2596 2593 RTGETOPTUNION ValueUnion; 2597 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)2598 { 2599 switch ( rc)2594 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 2595 { 2596 switch (vrc) 2600 2597 { 2601 2598 MEDIUMIOCOMMONOPT_CASES(pCommonOpts); … … 2609 2606 case 'v': // --variant 2610 2607 { 2611 intvrc = parseMediumVariant(ValueUnion.psz, &enmMediumVariant);2608 vrc = parseMediumVariant(ValueUnion.psz, &enmMediumVariant); 2612 2609 if (RT_FAILURE(vrc)) 2613 2610 return errorArgument(Disk::tr("Invalid medium variant '%s'"), ValueUnion.psz); … … 2616 2613 2617 2614 default: 2618 return errorGetOpt( rc, &ValueUnion);2615 return errorGetOpt(vrc, &ValueUnion); 2619 2616 } 2620 2617 } … … 2634 2631 if (pszOutput && (pszOutput[0] != '-' || pszOutput[1] != '\0')) 2635 2632 { 2636 intvrc = RTStrmOpen(pszOutput, "wb", &pOut);2633 vrc = RTStrmOpen(pszOutput, "wb", &pOut); 2637 2634 if (RT_FAILURE(vrc)) 2638 2635 rcExit = RTMsgErrorExitFailure(Disk::tr("Error opening '%s' for writing: %Rrc"), pszOutput, vrc); … … 2676 2673 { 2677 2674 BYTE const *pbBuf = SafeArrayBuf.raw(); 2678 int vrc = VINF_SUCCESS;2679 2675 vrc = RTStrmWrite(pOut, pbBuf, cbReturned); 2680 2676 if (RT_FAILURE(vrc)) … … 2699 2695 if (pOut != g_pStdOut) 2700 2696 { 2701 intvrc = RTStrmClose(pOut);2697 vrc = RTStrmClose(pOut); 2702 2698 if (RT_FAILURE(vrc)) 2703 2699 rcExit = RTMsgErrorExitFailure(Disk::tr("Error closing '%s': %Rrc"), pszOutput, vrc); … … 2727 2723 2728 2724 RTGETOPTSTATE GetState; 2729 int rc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0);2730 AssertRC (rc);2725 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0); 2726 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 2731 2727 RTGETOPTUNION ValueUnion; 2732 while (( rc = RTGetOpt(&GetState, &ValueUnion)) != 0)2733 { 2734 switch ( rc)2728 while ((vrc = RTGetOpt(&GetState, &ValueUnion)) != 0) 2729 { 2730 switch (vrc) 2735 2731 { 2736 2732 MEDIUMIOCOMMONOPT_CASES(&CommonOpts); … … 2751 2747 2752 2748 default: 2753 return errorGetOpt( rc, &ValueUnion);2749 return errorGetOpt(vrc, &ValueUnion); 2754 2750 } 2755 2751 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r98103 r98298 279 279 g_fGuestCtrlCanceled = false; 280 280 281 int rc = VINF_SUCCESS;281 int vrc = VINF_SUCCESS; 282 282 #ifdef RT_OS_WINDOWS 283 283 if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)gctlSignalHandler, TRUE /* Add handler */)) 284 284 { 285 rc = RTErrConvertFromWin32(GetLastError());286 RTMsgError(GuestCtrl::tr("Unable to install console control handler, rc=%Rrc\n"),rc);285 vrc = RTErrConvertFromWin32(GetLastError()); 286 RTMsgError(GuestCtrl::tr("Unable to install console control handler, vrc=%Rrc\n"), vrc); 287 287 } 288 288 #else … … 294 294 #endif 295 295 296 if (RT_SUCCESS( rc))297 rc = RTSemEventCreate(&g_SemEventGuestCtrlCanceled);298 299 return rc;296 if (RT_SUCCESS(vrc)) 297 vrc = RTSemEventCreate(&g_SemEventGuestCtrlCanceled); 298 299 return vrc; 300 300 } 301 301 … … 306 306 static int gctlSignalHandlerUninstall(void) 307 307 { 308 int rc = VINF_SUCCESS;308 int vrc = VINF_SUCCESS; 309 309 #ifdef RT_OS_WINDOWS 310 310 if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)NULL, FALSE /* Remove handler */)) 311 311 { 312 rc = RTErrConvertFromWin32(GetLastError());313 RTMsgError(GuestCtrl::tr("Unable to uninstall console control handler, rc=%Rrc\n"),rc);312 vrc = RTErrConvertFromWin32(GetLastError()); 313 RTMsgError(GuestCtrl::tr("Unable to uninstall console control handler, vrc=%Rrc\n"), vrc); 314 314 } 315 315 #else … … 326 326 g_SemEventGuestCtrlCanceled = NIL_RTSEMEVENT; 327 327 } 328 return rc;328 return vrc; 329 329 } 330 330 … … 572 572 */ 573 573 char szUser[1024]; 574 int rc = RTProcQueryUsername(RTProcSelf(), szUser, sizeof(szUser), NULL);575 if ( RT_SUCCESS( rc)574 int vrc = RTProcQueryUsername(RTProcSelf(), szUser, sizeof(szUser), NULL); 575 if ( RT_SUCCESS(vrc) 576 576 && RTStrIsValidEncoding(szUser)) /* paranoia was required on posix at some point, not needed any more! */ 577 577 { … … 853 853 if (!(pCtx->pCmdDef->fCmdCtx & GCTLCMDCTX_F_NO_SIGNAL_HANDLER)) 854 854 { 855 int rc = gctlSignalHandlerInstall();856 pCtx->fInstalledSignalHandler = RT_SUCCESS( rc);855 int vrc = gctlSignalHandlerInstall(); 856 pCtx->fInstalledSignalHandler = RT_SUCCESS(vrc); 857 857 } 858 858 } … … 1066 1066 vrc = RTVfsIoStrmWrite(hVfsIosDst, pbBuf, cbOutputData, true /*fBlocking*/, NULL); 1067 1067 if (RT_FAILURE(vrc)) 1068 RTMsgError(GuestCtrl::tr("Unable to write output, rc=%Rrc\n"), vrc);1068 RTMsgError(GuestCtrl::tr("Unable to write output, vrc=%Rrc\n"), vrc); 1069 1069 } 1070 1070 } … … 1762 1762 1763 1763 if (RT_FAILURE(vrc)) 1764 return RTMsgErrorExitFailure(GuestCtrl::tr("Error looking file system information for source '%s', rc=%Rrc"),1764 return RTMsgErrorExitFailure(GuestCtrl::tr("Error looking file system information for source '%s', vrc=%Rrc"), 1765 1765 papszSources[iSrc], vrc); 1766 1766 … … 2157 2157 2158 2158 if (RT_FAILURE(vrc)) 2159 return RTMsgErrorExit(RTEXITCODE_FAILURE, GuestCtrl::tr("Failed to initialize, rc=%Rrc\n"), vrc);2159 return RTMsgErrorExit(RTEXITCODE_FAILURE, GuestCtrl::tr("Failed to initialize, vrc=%Rrc\n"), vrc); 2160 2160 2161 2161 size_t cSources = vecSources.size(); … … 2736 2736 #if 0 2737 2737 ComPtr<IGuest> guest; 2738 rc = pConsole->COMGETTER(Guest)(guest.asOutParam());2738 HRESULT hrc = pConsole->COMGETTER(Guest)(guest.asOutParam()); 2739 2739 if (SUCCEEDED(hrc) && !guest.isNull()) 2740 2740 { … … 2742 2742 2743 2743 AdditionsRunLevelType_T guestRunLevel; /** @todo Add a runlevel-to-string (e.g. 0 = "None") method? */ 2744 rc = guest->COMGETTER(AdditionsRunLevel)(&guestRunLevel);2744 hrc = guest->COMGETTER(AdditionsRunLevel)(&guestRunLevel); 2745 2745 if (SUCCEEDED(hrc)) 2746 2746 SHOW_ULONG_VALUE("GuestAdditionsRunLevel", GuestCtrl::tr("Additions run level:"), (ULONG)guestRunLevel, ""); 2747 2747 2748 2748 Bstr guestString; 2749 rc = guest->COMGETTER(AdditionsVersion)(guestString.asOutParam());2749 hrc = guest->COMGETTER(AdditionsVersion)(guestString.asOutParam()); 2750 2750 if ( SUCCEEDED(hrc) 2751 2751 && !guestString.isEmpty()) 2752 2752 { 2753 2753 ULONG uRevision; 2754 rc = guest->COMGETTER(AdditionsRevision)(&uRevision);2754 hrc = guest->COMGETTER(AdditionsRevision)(&uRevision); 2755 2755 if (FAILED(hrc)) 2756 2756 uRevision = 0; … … 3170 3170 RTGETOPTUNION ValueUnion; 3171 3171 RTGETOPTSTATE GetState; 3172 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST); 3172 int vrc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST); 3173 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 3173 3174 3174 3175 std::vector < uint32_t > vecPID; … … 3195 3196 /* Treat every else specified as a PID to kill. */ 3196 3197 uint32_t uPid; 3197 intrc = RTStrToUInt32Ex(ValueUnion.psz, NULL, 0, &uPid);3198 if ( RT_SUCCESS( rc)3199 && rc != VWRN_TRAILING_CHARS3200 && rc != VWRN_NUMBER_TOO_BIG3201 && rc != VWRN_NEGATIVE_UNSIGNED)3198 vrc = RTStrToUInt32Ex(ValueUnion.psz, NULL, 0, &uPid); 3199 if ( RT_SUCCESS(vrc) 3200 && vrc != VWRN_TRAILING_CHARS 3201 && vrc != VWRN_NUMBER_TOO_BIG 3202 && vrc != VWRN_NEGATIVE_UNSIGNED) 3202 3203 { 3203 3204 if (uPid != 0) … … 3216 3217 } 3217 3218 else 3218 return errorSyntax(GuestCtrl::tr("Error parsing PID value: %Rrc"), rc);3219 return errorSyntax(GuestCtrl::tr("Error parsing PID value: %Rrc"), vrc); 3219 3220 break; 3220 3221 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r98103 r98298 467 467 vrc = RTPathAbs(ValueUnion.psz, szTargetFolder, sizeof(szTargetFolder)); 468 468 if (RT_FAILURE(vrc)) 469 return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("RTPathAbs(%s,,) failed with rc=%Rrc"),469 return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("RTPathAbs(%s,,) failed with vrc=%Rrc"), 470 470 ValueUnion.psz, vrc); 471 471 } else { … … 488 488 489 489 if (!pszType) 490 {491 490 pszType = "basic"; 492 }493 491 494 492 /* Check for required options */ … … 558 556 static int parseCloneOptions(const char *psz, com::SafeArray<CloneOptions_T> *options) 559 557 { 560 int rc = VINF_SUCCESS;561 while (psz && *psz && RT_SUCCESS( rc))558 int vrc = VINF_SUCCESS; 559 while (psz && *psz && RT_SUCCESS(vrc)) 562 560 { 563 561 size_t len; … … 582 580 options->push_back(CloneOptions_KeepHwUUIDs); 583 581 else 584 rc = VERR_PARSE_ERROR;582 vrc = VERR_PARSE_ERROR; 585 583 } 586 584 if (pszComma) … … 590 588 } 591 589 592 return rc;590 return vrc; 593 591 } 594 592 … … 1865 1863 int vrc = RTPathAbs(pszName, szPath, sizeof(szPath)); 1866 1864 if (RT_FAILURE(vrc)) 1867 return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("RTPathAbs(%s,,) failed with rc=%Rrc"), pszName, vrc);1865 return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("RTPathAbs(%s,,) failed with vrc=%Rrc"), pszName, vrc); 1868 1866 1869 1867 Bstr bstrTarball(szPath); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r98103 r98298 517 517 static int32_t parsePci(const char* szPciAddr) 518 518 { 519 char* pszNext = (char*)szPciAddr;520 int rc;521 519 uint8_t aVals[3] = {0, 0, 0}; 522 520 523 rc = RTStrToUInt8Ex(pszNext, &pszNext, 16, &aVals[0]); 524 if (RT_FAILURE(rc) || pszNext == NULL || *pszNext != ':') 521 char *pszNext; 522 int vrc = RTStrToUInt8Ex(pszNext, &pszNext, 16, &aVals[0]); 523 if (RT_FAILURE(vrc) || pszNext == NULL || *pszNext != ':') 525 524 return -1; 526 525 527 rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[1]);528 if (RT_FAILURE( rc) || pszNext == NULL || *pszNext != '.')526 vrc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[1]); 527 if (RT_FAILURE(vrc) || pszNext == NULL || *pszNext != '.') 529 528 return -1; 530 529 531 rc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[2]);532 if (RT_FAILURE( rc) || pszNext == NULL)530 vrc = RTStrToUInt8Ex(pszNext+1, &pszNext, 16, &aVals[2]); 531 if (RT_FAILURE(vrc) || pszNext == NULL) 533 532 return -1; 534 533 … … 574 573 char *pszNext; 575 574 uint32_t iScreen; 576 int rc = RTStrToUInt32Ex(pcszScreens, &pszNext, 0, &iScreen);577 if (RT_FAILURE( rc))575 int vrc = RTStrToUInt32Ex(pcszScreens, &pszNext, 0, &iScreen); 576 if (RT_FAILURE(vrc)) 578 577 return VERR_PARSE_ERROR; 579 578 if (iScreen >= pScreens->size()) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r98103 r98298 285 285 static int parseSnapshotUniqueFlags(const char *psz, SnapshotUniqueFlags *pUnique) 286 286 { 287 int rc = VINF_SUCCESS;287 int vrc = VINF_SUCCESS; 288 288 unsigned uUnique = 0; 289 while (psz && *psz && RT_SUCCESS( rc))289 while (psz && *psz && RT_SUCCESS(vrc)) 290 290 { 291 291 size_t len; … … 306 306 uUnique |= SnapshotUniqueFlags_Force; 307 307 else 308 rc = VERR_PARSE_ERROR;308 vrc = VERR_PARSE_ERROR; 309 309 } 310 310 if (pszComma) … … 314 314 } 315 315 316 if (RT_SUCCESS( rc))316 if (RT_SUCCESS(vrc)) 317 317 *pUnique = (SnapshotUniqueFlags)uUnique; 318 return rc;318 return vrc; 319 319 } 320 320
Note:
See TracChangeset
for help on using the changeset viewer.

