Nikolay Sivov : msi: Use VARIANT_BOOL values consistently for VT_BOOL type (PVS-Studio).

Alexandre Julliard julliard at wine.codeweavers.com
Wed Oct 21 10:39:59 CDT 2015


Module: wine
Branch: master
Commit: 2257928a7af1de0c1702b252ebb7f1dd9647b1f8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2257928a7af1de0c1702b252ebb7f1dd9647b1f8

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Oct 21 14:59:49 2015 +0300

msi: Use VARIANT_BOOL values consistently for VT_BOOL type (PVS-Studio).

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msi/automation.c       |  4 ++--
 dlls/msi/tests/automation.c | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/dlls/msi/automation.c b/dlls/msi/automation.c
index 56823ee..c3d2c67 100644
--- a/dlls/msi/automation.c
+++ b/dlls/msi/automation.c
@@ -1437,7 +1437,7 @@ static HRESULT session_invoke(
                 hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
                 if (FAILED(hr)) return hr;
                 V_VT(pVarResult) = VT_BOOL;
-                V_BOOL(pVarResult) = MsiGetMode(This->msiHandle, V_I4(&varg0));
+                V_BOOL(pVarResult) = MsiGetMode(This->msiHandle, V_I4(&varg0)) ? VARIANT_TRUE : VARIANT_FALSE;
             } else if (wFlags & DISPATCH_PROPERTYPUT) {
                 hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
                 if (FAILED(hr)) return hr;
@@ -2053,7 +2053,7 @@ static HRESULT InstallerImpl_RegistryValue(WORD wFlags,
         /* Return VT_BOOL clarifying whether registry key exists or not. */
         case VT_EMPTY:
             V_VT(pVarResult) = VT_BOOL;
-            V_BOOL(pVarResult) = (ret == ERROR_SUCCESS);
+            V_BOOL(pVarResult) = (ret == ERROR_SUCCESS) ? VARIANT_TRUE : VARIANT_FALSE;
             break;
 
         /* Return the value of specified key if it exists. */
diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c
index e31527f..a1df3f1 100644
--- a/dlls/msi/tests/automation.c
+++ b/dlls/msi/tests/automation.c
@@ -1204,7 +1204,7 @@ static HRESULT Session_LanguageGet(IDispatch *pSession, UINT *pLangId)
     return hr;
 }
 
-static HRESULT Session_ModeGet(IDispatch *pSession, int iFlag, BOOL *pMode)
+static HRESULT Session_ModeGet(IDispatch *pSession, int iFlag, VARIANT_BOOL *mode)
 {
     VARIANT varresult;
     VARIANTARG vararg[1];
@@ -1216,12 +1216,12 @@ static HRESULT Session_ModeGet(IDispatch *pSession, int iFlag, BOOL *pMode)
     V_I4(&vararg[0]) = iFlag;
 
     hr = invoke(pSession, "Mode", DISPATCH_PROPERTYGET, &dispparams, &varresult, VT_BOOL);
-    *pMode = V_BOOL(&varresult);
+    *mode = V_BOOL(&varresult);
     VariantClear(&varresult);
     return hr;
 }
 
-static HRESULT Session_ModePut(IDispatch *pSession, int iFlag, BOOL bMode)
+static HRESULT Session_ModePut(IDispatch *pSession, int iFlag, VARIANT_BOOL mode)
 {
     VARIANT varresult;
     VARIANTARG vararg[2];
@@ -1233,7 +1233,7 @@ static HRESULT Session_ModePut(IDispatch *pSession, int iFlag, BOOL bMode)
     V_I4(&vararg[1]) = iFlag;
     VariantInit(&vararg[0]);
     V_VT(&vararg[0]) = VT_BOOL;
-    V_BOOL(&vararg[0]) = bMode;
+    V_BOOL(&vararg[0]) = mode;
 
     return invoke(pSession, "Mode", DISPATCH_PROPERTYPUT, &dispparams, &varresult, VT_EMPTY);
 }
@@ -1876,7 +1876,7 @@ static void test_Session(IDispatch *pSession)
     WCHAR stringw[MAX_PATH];
     CHAR string[MAX_PATH];
     UINT len;
-    BOOL bool;
+    VARIANT_BOOL bool;
     int myint;
     IDispatch *pDatabase = NULL, *pInst = NULL, *record = NULL;
     ULONG refs_before, refs_after;
@@ -1944,15 +1944,15 @@ static void test_Session(IDispatch *pSession)
     ok(!bool, "Maintenance mode is %d\n", bool);
 
     /* Session::Mode, put */
-    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, TRUE);
+    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, VARIANT_TRUE);
     ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
     hr = Session_ModeGet(pSession, MSIRUNMODE_REBOOTATEND, &bool);
     ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr);
     ok(bool, "Reboot at end session mode is %d, expected 1\n", bool);
-    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, FALSE);  /* set it again so we don't reboot */
+    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTATEND, VARIANT_FALSE);  /* set it again so we don't reboot */
     ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
 
-    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, TRUE);
+    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, VARIANT_TRUE);
     ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
     ok_exception(hr, szModeFlag);
 
@@ -1960,11 +1960,11 @@ static void test_Session(IDispatch *pSession)
     ok(hr == S_OK, "Session_ModeGet failed, hresult 0x%08x\n", hr);
     ok(bool, "Reboot now mode is %d, expected 1\n", bool);
 
-    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, FALSE);  /* set it again so we don't reboot */
+    hr = Session_ModePut(pSession, MSIRUNMODE_REBOOTNOW, VARIANT_FALSE);  /* set it again so we don't reboot */
     ok(hr == S_OK, "Session_ModePut failed, hresult 0x%08x\n", hr);
     ok_exception(hr, szModeFlag);
 
-    hr = Session_ModePut(pSession, MSIRUNMODE_MAINTENANCE, TRUE);
+    hr = Session_ModePut(pSession, MSIRUNMODE_MAINTENANCE, VARIANT_TRUE);
     ok(hr == DISP_E_EXCEPTION, "Session_ModePut failed, hresult 0x%08x\n", hr);
     ok_exception(hr, szModeFlag);
 




More information about the wine-cvs mailing list