Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1006 Bytes

File metadata and controls

52 lines (40 loc) · 1006 Bytes
title c33022
description C33022 warning for HRESULTs
keywords c33022
author hwisungi
ms.author hwisungi
ms.date 06/20/2020
ms.topic reference
f1_keywords
C33022
helpviewer_keywords
C33022
dev_langs
C++

C33022

Warning C33022: Potentially incorrect HRESULT usage detected (low confidence)

This is low-confidence warning for a function that returns HRESULT, if there is "FALSE" somewhere along the line that eventually returns it or assigns it to a variable that is returned.

Example

#include <Windows.h>

#define CHECK_RESULT(X) X ? S_OK : FALSE;
#define RETURN_RESULT(X) return CHECK_RESULT(X)

HRESULT foo()
{
    // ......
    RETURN_RESULT(FALSE);   // C33022
}

These warnings are corrected by using proper HRESULT value:

#include <Windows.h>

#define CHECK_RESULT(X) X ? S_OK : E_FAIL;
#define RETURN_RESULT(X) return CHECK_RESULT(X)

HRESULT foo()
{
    // ......
    RETURN_RESULT(FALSE);    // OK
}

See also

C33020