From 38a9a342c259f69cb8d27836fb931606597b5846 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Thu, 1 Dec 2022 18:11:47 -0800 Subject: [PATCH] Fix more SAL errors. --- include/PerfectHash.h | 29 ++++++++++++++++++++++---- src/PerfectHash/PerfectHashConstants.h | 2 -- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/PerfectHash.h b/include/PerfectHash.h index de4d1052..d77a5c21 100644 --- a/include/PerfectHash.h +++ b/include/PerfectHash.h @@ -4073,17 +4073,38 @@ IsValidPerfectHashEnumId( #define PH_BREAK() __debugbreak() +// +// Helper inline that decorates RaiseException() with _Analysis_noreturn_, +// which we need for SAL to grok our PH_RAISE() calls correctly. +// + +_Analysis_noreturn_ +FORCEINLINE +VOID +PhRaiseException( + _In_ DWORD dwExceptionCode, + _In_ DWORD dwExceptionFlags, + _In_ DWORD nNumberOfArguments, + _In_reads_opt_(nNumberOfArguments) CONST ULONG_PTR* lpArguments + ) +{ + RaiseException(dwExceptionCode, + dwExceptionFlags, + nNumberOfArguments, + lpArguments); +} + // // Helper macro for raising non-continuable exceptions. // #ifdef _DEBUG -#define PH_RAISE(Result) \ - __debugbreak(); \ - RaiseException((DWORD)Result, EXCEPTION_NONCONTINUABLE, 0, NULL) +#define PH_RAISE(Result) \ + __debugbreak(); \ + PhRaiseException((DWORD)Result, EXCEPTION_NONCONTINUABLE, 0, NULL) #else #define PH_RAISE(Result) \ - RaiseException((DWORD)Result, EXCEPTION_NONCONTINUABLE, 0, NULL) + PhRaiseException((DWORD)Result, EXCEPTION_NONCONTINUABLE, 0, NULL) #endif // diff --git a/src/PerfectHash/PerfectHashConstants.h b/src/PerfectHash/PerfectHashConstants.h index 5141c9b1..a557adab 100644 --- a/src/PerfectHash/PerfectHashConstants.h +++ b/src/PerfectHash/PerfectHashConstants.h @@ -467,7 +467,6 @@ GetFileWorkItemStreamName( } FORCEINLINE -_Must_inspect_result_ _Success_(return != 0) PCUNICODE_STRING GetFileWorkItemBaseName( @@ -481,7 +480,6 @@ GetFileWorkItemBaseName( } FORCEINLINE -_Must_inspect_result_ _Success_(return != 0) PCUNICODE_STRING GetFileWorkItemExtension(