Examples of errors detected by the V543 diagnostic
V543. It is suspicious that value 'X' is assigned to the variable 'Y' of HRESULT type.
WinMerge
V543 It is odd that value '-1' is assigned to the variable 'h' of HRESULT type. Merge plugins.cpp 992
static HRESULT safeInvokeA(LPDISPATCH pi, VARIANT *ret,
DISPID id, LPCCH op, ...)
{
HRESULT h;
....
// set h to FAILED
h = -1;
....
}
Similar errors can be found in some other places:
- V543 It is odd that value '-1' is assigned to the variable 'h' of HRESULT type. Merge plugins.cpp 1033
Oracle VM Virtual Box
V543 It is odd that value 'true' is assigned to the variable 'mRemoveSavedState' of HRESULT type. machineimpl.cpp 12247
class ATL_NO_VTABLE SessionMachine : public Machine
{
....
HRESULT mRemoveSavedState;
....
}
HRESULT SessionMachine::init(Machine *aMachine)
{
....
/* default is to delete saved state on
* Saved -> PoweredOff transition */
mRemoveSavedState = true;
....
}
Unreal Engine 4
V543 It is odd that value '-1' is assigned to the variable 'Result' of HRESULT type. unrealaudiodevicewasapi.cpp 568
#define S_OK ((HRESULT)0L)
#define S_FALSE ((HRESULT)1L)
bool FUnrealAudioWasapi::OpenDevice(uint32 DeviceIndex,
EStreamType::Type StreamType)
{
check(WasapiInfo.DeviceEnumerator);
IMMDevice* Device = nullptr;
IMMDeviceCollection* DeviceList = nullptr;
WAVEFORMATEX* DeviceFormat = nullptr;
FDeviceInfo DeviceInfo;
HRESULT Result = S_OK; // <=
....
if (!GetDeviceInfo(DataFlow, DeviceIndex, DeviceInfo))
{
Result = -1; // <=
goto Cleanup;
}
....
}
Mozilla Thunderbird
V543 It is odd that value '-1' is assigned to the variable 'm_lastError' of HRESULT type. MapiApi.cpp 1050
class CMapiApi {
....
private:
static HRESULT m_lastError;
....
};
CMsgStore *CMapiApi::FindMessageStore(ULONG cbEid, LPENTRYID lpEid) {
if (!m_lpSession) {
MAPI_TRACE0("FindMessageStore called before session is open\n");
m_lastError = -1;
return NULL;
}
....
}
Similar errors can be found in some other places:
- V543 It is odd that value '-1' is assigned to the variable 'm_lastError' of HRESULT type. MapiApi.cpp 817
- V543 It is odd that value '-1' is assigned to the variable 'm_lastError' of HRESULT type. MapiApi.cpp 1749