@joebigelow / wix-1 / commits / 7d56566b

Update balutil and Bal.wixext to use more concise Exit* macros.

Sean Hall committed May 13, 2022 at 13:49 UTC 7d56566b7c51c49ded526466dfae6af9e1709040
8 files changed +85 -157
src/api/burn/balutil/balcondition.cpp
+2 -2
@@ -35,10 +35,10 @@ DAPI_(HRESULT) BalConditionsParseFromXml(
35 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
36 {
37 hr = XmlGetAttributeEx(pNode, L"Condition", &prgConditions[iCondition].sczCondition);
38 - ExitOnFailure(hr, "Failed to get condition for condition.");
38 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get condition for condition.");
39
40 hr = XmlGetAttributeEx(pNode, L"Message", &prgConditions[iCondition].sczMessage);
41 - ExitOnFailure(hr, "Failed to get message for condition.");
41 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get message for condition.");
42
43 if (pWixLoc && prgConditions[iCondition].sczMessage && *prgConditions[iCondition].sczMessage)
44 {
src/api/burn/balutil/balinfo.cpp
+30 -75
@@ -123,29 +123,21 @@ DAPI_(HRESULT) BalInfoParseFromXml(
123 {
124 HRESULT hr = S_OK;
125 IXMLDOMNode* pNode = NULL;
126 + BOOL fXmlFound = FALSE;
127
128 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBundleProperties", &pNode);
128 - ExitOnFailure(hr, "Failed to select bundle information.");
129 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to select bundle information.");
130
130 - if (S_OK == hr)
131 + if (fXmlFound)
132 {
133 hr = XmlGetYesNoAttribute(pNode, L"PerMachine", &pBundle->fPerMachine);
133 - if (E_NOTFOUND != hr)
134 - {
135 - ExitOnFailure(hr, "Failed to read bundle information per-machine.");
136 - }
134 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to read bundle information per-machine.");
135
136 hr = XmlGetAttributeEx(pNode, L"DisplayName", &pBundle->sczName);
139 - if (E_NOTFOUND != hr)
140 - {
141 - ExitOnFailure(hr, "Failed to read bundle information display name.");
142 - }
137 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to read bundle information display name.");
138
139 hr = XmlGetAttributeEx(pNode, L"LogPathVariable", &pBundle->sczLogVariable);
145 - if (E_NOTFOUND != hr)
146 - {
147 - ExitOnFailure(hr, "Failed to read bundle information log path variable.");
148 - }
140 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to read bundle information log path variable.");
141 }
142
143 hr = ParseOverridableVariablesFromXml(&pBundle->overridableVariables, pixdManifest);
@@ -192,7 +184,7 @@ DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage(
184 break;
185
186 default:
195 - ExitOnFailure(hr = E_INVALIDARG, "Unknown related bundle type: %u", relationType);
187 + ExitWithRootFailure(hr, E_INVALIDARG, "Unknown related bundle type: %u", relationType);
188 }
189
190 // Check to see if the bundle is already in the list of packages.
@@ -403,6 +395,7 @@ static HRESULT ParsePackagesFromXml(
395 BAL_INFO_PACKAGE* prgPackages = NULL;
396 DWORD cPackages = 0;
397 LPWSTR scz = NULL;
398 + BOOL fXmlFound = FALSE;
399
400 hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPackageProperties", &pNodeList);
401 ExitOnFailure(hr, "Failed to select all packages.");
@@ -417,22 +410,16 @@ static HRESULT ParsePackagesFromXml(
410 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
411 {
412 hr = XmlGetAttributeEx(pNode, L"Package", &prgPackages[iPackage].sczId);
420 - ExitOnFailure(hr, "Failed to get package identifier for package.");
413 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get package identifier for package.");
414
415 hr = XmlGetAttributeEx(pNode, L"DisplayName", &prgPackages[iPackage].sczDisplayName);
423 - if (E_NOTFOUND != hr)
424 - {
425 - ExitOnFailure(hr, "Failed to get display name for package.");
426 - }
416 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get display name for package.");
417
418 hr = XmlGetAttributeEx(pNode, L"Description", &prgPackages[iPackage].sczDescription);
429 - if (E_NOTFOUND != hr)
430 - {
431 - ExitOnFailure(hr, "Failed to get description for package.");
432 - }
419 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get description for package.");
420
421 hr = XmlGetAttributeEx(pNode, L"PackageType", &scz);
435 - ExitOnFailure(hr, "Failed to get package type for package.");
422 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get package type for package.");
423
424 if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Bundle", -1, scz, -1))
425 {
@@ -456,43 +443,28 @@ static HRESULT ParsePackagesFromXml(
443 }
444
445 hr = XmlGetYesNoAttribute(pNode, L"Permanent", &prgPackages[iPackage].fPermanent);
459 - ExitOnFailure(hr, "Failed to get permanent setting for package.");
446 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get permanent setting for package.");
447
448 hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital);
462 - ExitOnFailure(hr, "Failed to get vital setting for package.");
449 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get vital setting for package.");
450
451 hr = XmlGetAttributeEx(pNode, L"ProductCode", &prgPackages[iPackage].sczProductCode);
465 - if (E_NOTFOUND != hr)
466 - {
467 - ExitOnFailure(hr, "Failed to get product code for package.");
468 - }
452 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get product code for package.");
453
454 hr = XmlGetAttributeEx(pNode, L"UpgradeCode", &prgPackages[iPackage].sczUpgradeCode);
471 - if (E_NOTFOUND != hr)
472 - {
473 - ExitOnFailure(hr, "Failed to get upgrade code for package.");
474 - }
455 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get upgrade code for package.");
456
457 hr = XmlGetAttributeEx(pNode, L"Version", &prgPackages[iPackage].sczVersion);
477 - if (E_NOTFOUND != hr)
478 - {
479 - ExitOnFailure(hr, "Failed to get version for package.");
480 - }
458 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get version for package.");
459
460 hr = XmlGetAttributeEx(pNode, L"InstallCondition", &prgPackages[iPackage].sczInstallCondition);
483 - if (E_NOTFOUND != hr)
484 - {
485 - ExitOnFailure(hr, "Failed to get install condition for package.");
486 - }
461 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get install condition for package.");
462
463 hr = XmlGetAttributeEx(pNode, L"RepairCondition", &prgPackages[iPackage].sczRepairCondition);
489 - if (E_NOTFOUND != hr)
490 - {
491 - ExitOnFailure(hr, "Failed to get repair condition for package.");
492 - }
464 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get repair condition for package.");
465
466 hr = XmlGetAttributeEx(pNode, L"Cache", &scz);
495 - ExitOnFailure(hr, "Failed to get cache type for package.");
467 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get cache type for package.");
468
469 if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, scz, -1, L"remove", -1))
470 {
@@ -541,6 +513,7 @@ static HRESULT ParseBalPackageInfoFromXml(
513 IXMLDOMNode* pNode = NULL;
514 LPWSTR scz = NULL;
515 BAL_INFO_PACKAGE* pPackage = NULL;
516 + BOOL fXmlFound = FALSE;
517
518 hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixBalPackageInfo", &pNodeList);
519 ExitOnFailure(hr, "Failed to select all packages.");
@@ -548,16 +521,13 @@ static HRESULT ParseBalPackageInfoFromXml(
521 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
522 {
523 hr = XmlGetAttributeEx(pNode, L"PackageId", &scz);
551 - ExitOnFailure(hr, "Failed to get package identifier for WixBalPackageInfo.");
524 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get package identifier for WixBalPackageInfo.");
525
526 hr = BalInfoFindPackageById(pPackages, scz, &pPackage);
527 ExitOnFailure(hr, "Failed to find package specified in WixBalPackageInfo: %ls", scz);
528
529 hr = XmlGetAttributeEx(pNode, L"DisplayInternalUICondition", &pPackage->sczDisplayInternalUICondition);
557 - if (E_NOTFOUND != hr)
558 - {
559 - ExitOnFailure(hr, "Failed to get DisplayInternalUICondition setting for package.");
560 - }
530 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get DisplayInternalUICondition setting for package.");
531
532 ReleaseNullObject(pNode);
533 }
@@ -569,7 +539,7 @@ static HRESULT ParseBalPackageInfoFromXml(
539 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
540 {
541 hr = XmlGetAttributeEx(pNode, L"PackageId", &scz);
572 - ExitOnFailure(hr, "Failed to get package identifier for WixMbaPrereqInformation.");
542 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get package identifier for WixMbaPrereqInformation.");
543
544 hr = BalInfoFindPackageById(pPackages, scz, &pPackage);
545 ExitOnFailure(hr, "Failed to find package specified in WixMbaPrereqInformation: %ls", scz);
@@ -577,16 +547,10 @@ static HRESULT ParseBalPackageInfoFromXml(
547 pPackage->fPrereqPackage = TRUE;
548
549 hr = XmlGetAttributeEx(pNode, L"LicenseFile", &pPackage->sczPrereqLicenseFile);
580 - if (E_NOTFOUND != hr)
581 - {
582 - ExitOnFailure(hr, "Failed to get LicenseFile setting for prereq package.");
583 - }
550 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get LicenseFile setting for prereq package.");
551
552 hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &pPackage->sczPrereqLicenseUrl);
586 - if (E_NOTFOUND != hr)
587 - {
588 - ExitOnFailure(hr, "Failed to get LicenseUrl setting for prereq package.");
589 - }
553 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get LicenseUrl setting for prereq package.");
554
555 ReleaseNullObject(pNode);
556 }
@@ -619,15 +583,11 @@ static HRESULT ParseOverridableVariablesFromXml(
583 BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL;
584
585 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/CommandLine", &pCommandLineNode);
622 - if (S_FALSE == hr)
623 - {
624 - hr = E_NOTFOUND;
625 - }
626 - ExitOnFailure(hr, "Failed to select command line information.");
586 + ExitOnRequiredXmlQueryFailure(hr, "Failed to select command line information.");
587
588 // @Variables
589 hr = XmlGetAttributeEx(pCommandLineNode, L"Variables", &scz);
630 - ExitOnFailure(hr, "Failed to get command line variable type.");
590 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get command line variable type.");
591
592 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"upperCase", -1))
593 {
@@ -639,16 +599,11 @@ static HRESULT ParseOverridableVariablesFromXml(
599 }
600 else
601 {
642 - hr = E_INVALIDARG;
643 - ExitOnFailure(hr, "Invalid value for CommandLine/@Variables: %ls", scz);
602 + ExitWithRootFailure(hr, E_INVALIDARG, "Invalid value for CommandLine/@Variables: %ls", scz);
603 }
604
605 // Get the list of variables users can override on the command line.
606 hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOverridableVariable", &pNodes);
648 - if (S_FALSE == hr)
649 - {
650 - ExitFunction1(hr = S_OK);
651 - }
607 ExitOnFailure(hr, "Failed to select overridable variable nodes.");
608
609 hr = pNodes->get_length(reinterpret_cast<long*>(&pOverridableVariables->cVariables));
@@ -671,7 +626,7 @@ static HRESULT ParseOverridableVariablesFromXml(
626
627 // @Name
628 hr = XmlGetAttributeEx(pNode, L"Name", &pOverridableVariable->sczName);
674 - ExitOnFailure(hr, "Failed to get name for overridable variable.");
629 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get name for overridable variable.");
630
631 hr = DictAddValue(pOverridableVariables->sdVariables, pOverridableVariable);
632 ExitOnFailure(hr, "Failed to add \"%ls\" to the string dictionary.", pOverridableVariable->sczName);
src/api/burn/balutil/inc/balutil.h
+4
@@ -16,6 +16,8 @@ extern "C" {
16 #define BalExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
17 #define BalExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
18 #define BalExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
19 +#define BalExitOnOptionalXmlQueryFailureSource(d, x, b, f, ...) { { if (S_FALSE == x || E_NOTFOUND == x) { b = FALSE; x = S_OK; } else { b = SUCCEEDED(x); } }; BalExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
20 +#define BalExitOnRequiredXmlQueryFailureSource(d, x, f, ...) { if (S_FALSE == x) { x = E_NOTFOUND; } BalExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
21
22 #define BalExitOnFailure(x, f, ...) BalExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
23 #define BalExitOnRootFailure(x, f, ...) BalExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
@@ -24,6 +26,8 @@ extern "C" {
26 #define BalExitOnNull(p, x, e, f, ...) BalExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__)
27 #define BalExitOnNullWithLastError(p, x, f, ...) BalExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__)
28 #define BalExitWithLastError(x, f, ...) BalExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
29 +#define BalExitOnOptionalXmlQueryFailure(x, b, f, ...) BalExitOnOptionalXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, b, f, __VA_ARGS__)
30 +#define BalExitOnRequiredXmlQueryFailure(x, f, ...) BalExitOnRequiredXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
31
32 #ifndef FACILITY_WIX
33 #define FACILITY_WIX 500
src/api/burn/bextutil/bextutil.cpp
+1 -1
@@ -85,7 +85,7 @@ DAPI_(HRESULT) BextGetBundleExtensionDataNode(
85
86 // @Id
87 hr = XmlGetAttributeEx(pixnNode, L"Id", &sczId);
88 - ExitOnFailure(hr, "Failed to get @Id.");
88 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Id.");
89
90 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczId, -1, wzExtensionId, -1))
91 {
src/api/burn/bextutil/inc/bextutil.h
+4
@@ -16,6 +16,8 @@ extern "C" {
16 #define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
17 #define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
18 #define BextExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
19 +#define BextExitOnOptionalXmlQueryFailureSource(d, x, b, f, ...) { { if (S_FALSE == x || E_NOTFOUND == x) { b = FALSE; x = S_OK; } else { b = SUCCEEDED(x); } }; BextExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
20 +#define BextExitOnRequiredXmlQueryFailureSource(d, x, f, ...) { if (S_FALSE == x) { x = E_NOTFOUND; } BextExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
21
22 #define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
23 #define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
@@ -24,6 +26,8 @@ extern "C" {
26 #define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__)
27 #define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__)
28 #define BextExitWithLastError(x, f, ...) BextExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
29 +#define BextExitOnOptionalXmlQueryFailure(x, b, f, ...) BextExitOnOptionalXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, b, f, __VA_ARGS__)
30 +#define BextExitOnRequiredXmlQueryFailure(x, f, ...) BextExitOnRequiredXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
31
32 const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml";
33
src/ext/Bal/dnchost/dnchost.cpp
+10 -17
@@ -168,21 +168,16 @@ static HRESULT LoadDncConfiguration(
168 IXMLDOMNode* pixnHost = NULL;
169 LPWSTR sczPayloadName = NULL;
170 DWORD dwBool = 0;
171 + BOOL fXmlFound = FALSE;
172
173 hr = XmlLoadDocumentFromFile(pArgs->pCommand->wzBootstrapperApplicationDataPath, &pixdManifest);
174 BalExitOnFailure(hr, "Failed to load BalManifest '%ls'", pArgs->pCommand->wzBootstrapperApplicationDataPath);
175
176 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBalBAFactoryAssembly", &pixnHost);
176 - BalExitOnFailure(hr, "Failed to get WixBalBAFactoryAssembly element.");
177 -
178 - if (S_FALSE == hr)
179 - {
180 - hr = E_NOTFOUND;
181 - BalExitOnRootFailure(hr, "Failed to find WixBalBAFactoryAssembly element in bootstrapper application config.");
182 - }
177 + BalExitOnRequiredXmlQueryFailure(hr, "Failed to get WixBalBAFactoryAssembly element.");
178
179 hr = XmlGetAttributeEx(pixnHost, L"FilePath", &sczPayloadName);
185 - BalExitOnFailure(hr, "Failed to get WixBalBAFactoryAssembly/@FilePath.");
180 + BalExitOnRequiredXmlQueryFailure(hr, "Failed to get WixBalBAFactoryAssembly/@FilePath.");
181
182 hr = PathConcat(pArgs->pCommand->wzBootstrapperWorkingFolder, sczPayloadName, &pState->sczBaFactoryAssemblyPath);
183 BalExitOnFailure(hr, "Failed to create BaFactoryAssemblyPath.");
@@ -212,22 +207,20 @@ static HRESULT LoadDncConfiguration(
207 pState->type = DNCHOSTTYPE_FDD;
208
209 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixDncOptions", &pixnHost);
215 - if (S_FALSE == hr)
210 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to find WixDncOptions element in bootstrapper application config.");
211 +
212 + if (!fXmlFound)
213 {
217 - ExitFunction1(hr = S_OK);
214 + ExitFunction();
215 }
219 - BalExitOnFailure(hr, "Failed to find WixDncOptions element in bootstrapper application config.");
216
217 hr = XmlGetAttributeNumber(pixnHost, L"SelfContainedDeployment", &dwBool);
222 - if (S_FALSE == hr)
223 - {
224 - hr = S_OK;
225 - }
226 - else if (SUCCEEDED(hr) && dwBool)
218 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get SelfContainedDeployment value.");
219 +
220 + if (fXmlFound && dwBool)
221 {
222 pState->type = DNCHOSTTYPE_SCD;
223 }
230 - BalExitOnFailure(hr, "Failed to get SelfContainedDeployment value.");
224
225 LExit:
226 ReleaseStr(sczPayloadName);
src/ext/Bal/mbahost/mbahost.cpp
+7 -11
@@ -290,7 +290,7 @@ static HRESULT CheckSupportedFrameworks(
290 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
291 {
292 hr = XmlGetAttributeEx(pNode, L"version", &sczSupportedFrameworkVersion);
293 - ExitOnFailure(hr, "Failed to get supportedFramework/@version.");
293 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get supportedFramework/@version.");
294
295 hr = StrAllocFormatted(&sczFrameworkRegistryKey, L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\%ls", sczSupportedFrameworkVersion);
296 ExitOnFailure(hr, "Failed to allocate path to supported framework Install registry key.");
@@ -351,27 +351,23 @@ static HRESULT UpdateSupportedRuntime(
351 LPWSTR sczSupportedRuntimeVersion = NULL;
352 IXMLDOMNode* pixnStartup = NULL;
353 IXMLDOMNode* pixnSupportedRuntime = NULL;
354 + BOOL fXmlFound = FALSE;
355
356 *pfUpdatedManifest = FALSE;
357
358 // If the runtime version attribute is not specified, don't update the manifest.
359 hr = XmlGetAttributeEx(pixnSupportedFramework, L"runtimeVersion", &sczSupportedRuntimeVersion);
359 - if (E_NOTFOUND == hr)
360 + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get supportedFramework/@runtimeVersion.");
361 +
362 + if (!fXmlFound)
363 {
361 - ExitFunction1(hr = S_OK);
364 + ExitFunction();
365 }
363 - ExitOnFailure(hr, "Failed to get supportedFramework/@runtimeVersion.");
366
367 // Get the startup element. Fail if we can't find it since it'll be necessary to load the
368 // correct runtime.
369 hr = XmlSelectSingleNode(pixdManifest, L"/configuration/startup", &pixnStartup);
368 - ExitOnFailure(hr, "Failed to get startup element.");
369 -
370 - if (S_FALSE == hr)
371 - {
372 - hr = E_NOTFOUND;
373 - ExitOnRootFailure(hr, "Failed to find startup element in bootstrapper application config.");
374 - }
370 + ExitOnRequiredXmlQueryFailure(hr, "Failed to get startup element.");
371
372 // Remove any pre-existing supported runtimes because they'll just get in the way and create our new one.
373 hr = XmlRemoveChildren(pixnStartup, L"supportedRuntime");
src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+27 -51
@@ -2603,95 +2603,70 @@ private:
2603 HRESULT hr = S_OK;
2604 IXMLDOMNode* pNode = NULL;
2605 DWORD dwBool = 0;
2606 + BOOL fXmlFound = FALSE;
2607
2608 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixStdbaInformation", &pNode);
2608 - if (S_FALSE == hr)
2609 - {
2610 - hr = E_INVALIDARG;
2611 - }
2612 - BalExitOnFailure(hr, "BootstrapperApplication.xml manifest is missing wixstdba information.");
2609 + BalExitOnRequiredXmlQueryFailure(hr, "BootstrapperApplication.xml manifest is missing wixstdba information.");
2610
2611 hr = XmlGetAttributeEx(pNode, L"LicenseFile", &m_sczLicenseFile);
2615 - if (E_NOTFOUND == hr)
2616 - {
2617 - hr = S_OK;
2618 - }
2619 - BalExitOnFailure(hr, "Failed to get license file.");
2612 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get license file.");
2613
2614 hr = XmlGetAttributeEx(pNode, L"LicenseUrl", &m_sczLicenseUrl);
2622 - if (E_NOTFOUND == hr)
2623 - {
2624 - hr = S_OK;
2625 - }
2626 - BalExitOnFailure(hr, "Failed to get license URL.");
2615 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get license URL.");
2616
2617 ReleaseObject(pNode);
2618
2619 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOptions", &pNode);
2631 - if (S_FALSE == hr)
2620 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to read wixstdba options from BootstrapperApplication.xml manifest.");
2621 +
2622 + if (!fXmlFound)
2623 {
2633 - ExitFunction1(hr = S_OK);
2624 + ExitFunction();
2625 }
2635 - BalExitOnFailure(hr, "Failed to read wixstdba options from BootstrapperApplication.xml manifest.");
2626
2627 hr = XmlGetAttributeNumber(pNode, L"SuppressOptionsUI", &dwBool);
2638 - if (S_FALSE == hr)
2639 - {
2640 - hr = S_OK;
2641 - }
2642 - else if (SUCCEEDED(hr) && dwBool)
2628 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get SuppressOptionsUI value.");
2629 +
2630 + if (fXmlFound && dwBool)
2631 {
2632 hr = BalSetNumericVariable(WIXSTDBA_VARIABLE_SUPPRESS_OPTIONS_UI, 1);
2633 BalExitOnFailure(hr, "Failed to set '%ls' variable.", WIXSTDBA_VARIABLE_SUPPRESS_OPTIONS_UI);
2634 }
2647 - BalExitOnFailure(hr, "Failed to get SuppressOptionsUI value.");
2635
2636 dwBool = 0;
2637 hr = XmlGetAttributeNumber(pNode, L"SuppressDowngradeFailure", &dwBool);
2651 - if (S_FALSE == hr)
2652 - {
2653 - hr = S_OK;
2654 - }
2655 - else if (SUCCEEDED(hr))
2638 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get SuppressDowngradeFailure value.");
2639 +
2640 + if (fXmlFound)
2641 {
2642 m_fSuppressDowngradeFailure = 0 < dwBool;
2643 }
2659 - BalExitOnFailure(hr, "Failed to get SuppressDowngradeFailure value.");
2644
2645 dwBool = 0;
2646 hr = XmlGetAttributeNumber(pNode, L"SuppressRepair", &dwBool);
2663 - if (S_FALSE == hr)
2664 - {
2665 - hr = S_OK;
2666 - }
2667 - else if (SUCCEEDED(hr))
2647 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get SuppressRepair value.");
2648 +
2649 + if (fXmlFound)
2650 {
2651 m_fSuppressRepair = 0 < dwBool;
2652 }
2671 - BalExitOnFailure(hr, "Failed to get SuppressRepair value.");
2653
2654 hr = XmlGetAttributeNumber(pNode, L"ShowVersion", &dwBool);
2674 - if (S_FALSE == hr)
2675 - {
2676 - hr = S_OK;
2677 - }
2678 - else if (SUCCEEDED(hr) && dwBool)
2655 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get ShowVersion value.");
2656 +
2657 + if (fXmlFound && dwBool)
2658 {
2659 hr = BalSetNumericVariable(WIXSTDBA_VARIABLE_SHOW_VERSION, 1);
2660 BalExitOnFailure(hr, "Failed to set '%ls' variable.", WIXSTDBA_VARIABLE_SHOW_VERSION);
2661 }
2683 - BalExitOnFailure(hr, "Failed to get ShowVersion value.");
2662
2663 hr = XmlGetAttributeNumber(pNode, L"SupportCacheOnly", &dwBool);
2686 - if (S_FALSE == hr)
2687 - {
2688 - hr = S_OK;
2689 - }
2690 - else if (SUCCEEDED(hr))
2664 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get SupportCacheOnly value.");
2665 +
2666 + if (fXmlFound)
2667 {
2668 m_fSupportCacheOnly = 0 < dwBool;
2669 }
2694 - BalExitOnFailure(hr, "Failed to get SupportCacheOnly value.");
2670
2671 LExit:
2672 ReleaseObject(pNode);
@@ -4149,17 +4124,18 @@ LExit:
4124 LPWSTR sczBafPath = NULL;
4125 BA_FUNCTIONS_CREATE_ARGS bafCreateArgs = { };
4126 BA_FUNCTIONS_CREATE_RESULTS bafCreateResults = { };
4127 + BOOL fXmlFound = FALSE;
4128
4129 hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixBalBAFunctions", &pBAFunctionsNode);
4154 - BalExitOnFailure(hr, "Failed to read WixBalBAFunctions node from BootstrapperApplicationData.xml.");
4130 + BalExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to read WixBalBAFunctions node from BootstrapperApplicationData.xml.");
4131
4156 - if (S_FALSE == hr)
4132 + if (!fXmlFound)
4133 {
4134 ExitFunction();
4135 }
4136
4137 hr = XmlGetAttributeEx(pBAFunctionsNode, L"FilePath", &sczBafName);
4162 - BalExitOnFailure(hr, "Failed to get BAFunctions FilePath.");
4138 + BalExitOnRequiredXmlQueryFailure(hr, "Failed to get BAFunctions FilePath.");
4139
4140 hr = PathRelativeToModule(&sczBafPath, sczBafName, m_hModule);
4141 BalExitOnFailure(hr, "Failed to get path to BAFunctions DLL.");