This informs the compiler that no code will ever run after an assertion failure (unless NDEBUG is defined), which increases accuracy of compiler warnings and static analyses.
-- v5: include/msvcrt: Add noreturn attribute to _assert. include: Add noreturn attribute to RtlRaiseStatus.
From: Jinoh Kang jinoh.kang.kr@gmail.com
This informs the compiler that no code following a RtlRaiseStatus() call will execute, which increases the accuracy of compiler warnings and static analyses. --- dlls/ntdll/exception.c | 4 ++-- include/winternl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index 556b424ac6e..5b3076387d6 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -191,7 +191,7 @@ LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context ) * * Implementation of RtlRaiseStatus with a specific exception record. */ -void raise_status( NTSTATUS status, EXCEPTION_RECORD *rec ) +void DECLSPEC_NORETURN raise_status( NTSTATUS status, EXCEPTION_RECORD *rec ) { EXCEPTION_RECORD ExceptionRec;
@@ -208,7 +208,7 @@ void raise_status( NTSTATUS status, EXCEPTION_RECORD *rec ) * * Raise an exception with ExceptionCode = status */ -void WINAPI RtlRaiseStatus( NTSTATUS status ) +void DECLSPEC_NORETURN WINAPI RtlRaiseStatus( NTSTATUS status ) { raise_status( status, NULL ); } diff --git a/include/winternl.h b/include/winternl.h index 4097a574e34..a7f82073ad5 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -4516,7 +4516,7 @@ NTSYSAPI NTSTATUS WINAPI RtlQueryTimeZoneInformation(RTL_TIME_ZONE_INFORMATION* NTSYSAPI BOOL WINAPI RtlQueryUnbiasedInterruptTime(ULONGLONG*); NTSYSAPI NTSTATUS WINAPI RtlQueueWorkItem(PRTL_WORK_ITEM_ROUTINE,PVOID,ULONG); NTSYSAPI void WINAPI RtlRaiseException(PEXCEPTION_RECORD); -NTSYSAPI void WINAPI RtlRaiseStatus(NTSTATUS); +NTSYSAPI void DECLSPEC_NORETURN WINAPI RtlRaiseStatus(NTSTATUS); NTSYSAPI ULONG WINAPI RtlRandom(PULONG); NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE,ULONG,PVOID,SIZE_T) __WINE_ALLOC_SIZE(4) __WINE_DEALLOC(RtlFreeHeap,3); NTSYSAPI NTSTATUS WINAPI RtlRegisterWait(PHANDLE,HANDLE,RTL_WAITORTIMERCALLBACKFUNC,PVOID,ULONG,ULONG);
From: Jinoh Kang jinoh.kang.kr@gmail.com
This informs the compiler that no code following an assertion failure will execute (unless NDEBUG is defined), which increases the accuracy of compiler warnings and static analyses.
For assert.h, put DECLSPEC_NORETURN before the return type in the function declaration to remain consistent with other MSVCRT function declarations. --- dlls/msvcrt/exit.c | 4 ++-- dlls/ntdll/exception.c | 2 +- include/msvcrt/assert.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c index 6427b15bece..3a7b5ae0330 100644 --- a/dlls/msvcrt/exit.c +++ b/dlls/msvcrt/exit.c @@ -290,7 +290,7 @@ unsigned int CDECL _set_abort_behavior(unsigned int flags, unsigned int mask) /********************************************************************* * _wassert (MSVCRT.@) */ -void CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line) +void DECLSPEC_NORETURN CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line) { TRACE("(%s,%s,%d)\n", debugstr_w(str), debugstr_w(file), line);
@@ -311,7 +311,7 @@ void CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line) /********************************************************************* * _assert (MSVCRT.@) */ -void CDECL _assert(const char* str, const char* file, unsigned int line) +void DECLSPEC_NORETURN CDECL _assert(const char* str, const char* file, unsigned int line) { wchar_t strW[1024], fileW[1024];
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index 5b3076387d6..fc3e8982a98 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -623,7 +623,7 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base, /************************************************************* * _assert */ -void __cdecl _assert( const char *str, const char *file, unsigned int line ) +void DECLSPEC_NORETURN __cdecl _assert( const char *str, const char *file, unsigned int line ) { ERR( "%s:%u: Assertion failed %s\n", file, line, debugstr_a(str) ); RtlRaiseStatus( EXCEPTION_WINE_ASSERTION ); diff --git a/include/msvcrt/assert.h b/include/msvcrt/assert.h index 9a180f7e58d..26a9c0a7a5f 100644 --- a/include/msvcrt/assert.h +++ b/include/msvcrt/assert.h @@ -28,7 +28,7 @@ extern "C" { #ifdef NDEBUG #define assert(_expr) ((void)0) #else -_ACRTIMP void __cdecl _assert(const char *, const char *, unsigned int); +_ACRTIMP DECLSPEC_NORETURN void __cdecl _assert(const char *, const char *, unsigned int); #define assert(_expr) (void)((!!(_expr)) || (_assert(#_expr, __FILE__, __LINE__), 0)) #endif
On Sun Jan 29 15:30:54 2023 +0000, Jinoh Kang wrote:
Wrong commit message ("include/msvcrt").
Fixed.
This merge request was approved by Piotr Caban.