Skip to content

Commit

Permalink
Suppress warning C26814; Minor renaming and tidy-up. (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelriet authored Aug 27, 2024
1 parent 4c40705 commit eb9eb35
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 122 deletions.
11 changes: 5 additions & 6 deletions include/wil/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@

/// @cond
#if defined(_MSVC_LANG)
#define __WI_SUPPRESS_4127_S \
__pragma(warning(push)) __pragma(warning(disable : 4127)) __pragma(warning(disable : 26498)) __pragma(warning(disable : 4245))
#define __WI_SUPPRESS_4127_E __pragma(warning(pop))
#define __WI_SUPPRESS_NULLPTR_ANALYSIS __pragma(warning(suppress : 28285)) __pragma(warning(suppress : 6504))
#define __WI_SUPPRESS_BREAKING_WARNINGS_S __pragma(warning(push)) __pragma(warning(disable : 4127 26498 4245 26814))
#define __WI_SUPPRESS_BREAKING_WARNINGS_E __pragma(warning(pop))
#define __WI_SUPPRESS_NULLPTR_ANALYSIS __pragma(warning(suppress : 28285 6504))
#define __WI_SUPPRESS_NONINIT_ANALYSIS __pragma(warning(suppress : 26495))
#define __WI_SUPPRESS_NOEXCEPT_ANALYSIS __pragma(warning(suppress : 26439))
#else
#define __WI_SUPPRESS_4127_S
#define __WI_SUPPRESS_4127_E
#define __WI_SUPPRESS_BREAKING_WARNINGS_S
#define __WI_SUPPRESS_BREAKING_WARNINGS_E
#define __WI_SUPPRESS_NULLPTR_ANALYSIS
#define __WI_SUPPRESS_NONINIT_ANALYSIS
#define __WI_SUPPRESS_NOEXCEPT_ANALYSIS
Expand Down
16 changes: 8 additions & 8 deletions include/wil/nt_result_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// Helpers for return macros
/// @cond
#define __NT_RETURN_NTSTATUS(status, str) \
__WI_SUPPRESS_4127_S do \
__WI_SUPPRESS_BREAKING_WARNINGS_S do \
{ \
NTSTATUS __status = (status); \
if (FAILED_NTSTATUS(__status)) \
Expand All @@ -28,9 +28,9 @@
} \
return __status; \
} \
__WI_SUPPRESS_4127_E while ((void)0, 0)
__WI_SUPPRESS_BREAKING_WARNINGS_E while ((void)0, 0)
#define __NT_RETURN_NTSTATUS_MSG(status, str, fmt, ...) \
__WI_SUPPRESS_4127_S do \
__WI_SUPPRESS_BREAKING_WARNINGS_S do \
{ \
NTSTATUS __status = (status); \
if (FAILED_NTSTATUS(__status)) \
Expand All @@ -39,7 +39,7 @@
} \
return __status; \
} \
__WI_SUPPRESS_4127_E while ((void)0, 0)
__WI_SUPPRESS_BREAKING_WARNINGS_E while ((void)0, 0)
/// @endcond

//*****************************************************************************
Expand All @@ -55,27 +55,27 @@

// Conditionally returns failures (NTSTATUS) - always logs failures
#define NT_RETURN_IF_NTSTATUS_FAILED(status) \
__WI_SUPPRESS_4127_S do \
__WI_SUPPRESS_BREAKING_WARNINGS_S do \
{ \
const auto __statusRet = wil::verify_ntstatus(status); \
if (FAILED_NTSTATUS(__statusRet)) \
{ \
__NT_RETURN_NTSTATUS(__statusRet, #status); \
} \
} \
__WI_SUPPRESS_4127_E while ((void)0, 0)
__WI_SUPPRESS_BREAKING_WARNINGS_E while ((void)0, 0)

// Conditionally returns failures (NTSTATUS) - always logs a var-arg message on failure
#define NT_RETURN_IF_NTSTATUS_FAILED_MSG(status, fmt, ...) \
__WI_SUPPRESS_4127_S do \
__WI_SUPPRESS_BREAKING_WARNINGS_S do \
{ \
const auto __statusRet = wil::verify_ntstatus(status); \
if (FAILED_NTSTATUS(__statusRet)) \
{ \
__NT_RETURN_NTSTATUS_MSG(__statusRet, #status, fmt, ##__VA_ARGS__); \
} \
} \
__WI_SUPPRESS_4127_E while ((void)0, 0)
__WI_SUPPRESS_BREAKING_WARNINGS_E while ((void)0, 0)

//*****************************************************************************
// Macros to catch and convert exceptions on failure
Expand Down
Loading

0 comments on commit eb9eb35

Please sign in to comment.