Use VARIANT_TRUE and VARIANT_FALSE correctly

VARIANT_TRUE (-1) must be used with VARIANTs of boolean type, instead of TRUE
(1) which has a different value and can result in interoperability problems.

Thanks to PVS-Studio for finding this issue (V721 The VARIANT_BOOL type is
utilized incorrectly).
This commit is contained in:
Ilya Ivanov 2017-04-27 15:06:56 +03:00 committed by Vadim Zeitlin
parent 5d7726e3f1
commit b65a3ad736

View File

@ -251,24 +251,24 @@ public:
switch (dispIdMember)
{
case DISPID_AMBIENT_MESSAGEREFLECT:
V_BOOL(pVarResult)= FALSE;
V_BOOL(pVarResult)= VARIANT_FALSE;
return S_OK;
case DISPID_AMBIENT_DISPLAYASDEFAULT:
V_BOOL(pVarResult)= TRUE;
V_BOOL(pVarResult)= VARIANT_TRUE;
return S_OK;
case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
V_BOOL(pVarResult) = TRUE;
V_BOOL(pVarResult) = VARIANT_TRUE;
return S_OK;
case DISPID_AMBIENT_SILENT:
V_BOOL(pVarResult)= TRUE;
V_BOOL(pVarResult)= VARIANT_TRUE;
return S_OK;
case DISPID_AMBIENT_APPEARANCE:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_bAmbientAppearance;
pVarResult->boolVal = m_bAmbientAppearance ? VARIANT_TRUE : VARIANT_FALSE;
break;
case DISPID_AMBIENT_FORECOLOR:
@ -288,17 +288,17 @@ public:
case DISPID_AMBIENT_USERMODE:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_window->m_bAmbientUserMode;
pVarResult->boolVal = m_window->m_bAmbientUserMode ? VARIANT_TRUE : VARIANT_FALSE;
break;
case DISPID_AMBIENT_SHOWGRABHANDLES:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_bAmbientShowGrabHandles;
pVarResult->boolVal = m_bAmbientShowGrabHandles ? VARIANT_TRUE : VARIANT_FALSE;
break;
case DISPID_AMBIENT_SHOWHATCHING:
pVarResult->vt = VT_BOOL;
pVarResult->boolVal = m_bAmbientShowHatching;
pVarResult->boolVal = m_bAmbientShowHatching ? VARIANT_TRUE : VARIANT_FALSE;
break;
default: