From ccabdec2f8c2cb8c7740e018546a53a3e6e0ef22 Mon Sep 17 00:00:00 2001 From: Kim Lindberg Schwaner Date: Fri, 15 Aug 2025 20:09:28 +0200 Subject: [PATCH] Fix risk of Win32 timer setup call getting ignored (#1311) If a user configures the configASSERT macro to expand to nothing, a call to the Win32 API SetWaitableTimer() doesn't get compiled. This can happen if, for example, configASSERT(x) set defined as assert(x) (from assert.h) which expands to nothing when NDEBUG is set (common for "release" builds). --- portable/MSVC-MingW/port.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index 74dd777ef..540c4a4bc 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -152,6 +152,7 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter ) TickType_t xWaitTimeBetweenTicks = portTICK_PERIOD_MS; HANDLE hTimer = NULL; LARGE_INTEGER liDueTime; + BOOL bSuccess; /* Set the timer resolution to the maximum possible. */ if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR ) @@ -190,7 +191,8 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter ) /* Set the Waitable Timer. The timer is set to run periodically at every xWaitTimeBetweenTicks milliseconds. */ - configASSERT( SetWaitableTimer( hTimer, &liDueTime, xWaitTimeBetweenTicks, NULL, NULL, 0 ) ); + bSuccess = SetWaitableTimer( hTimer, &liDueTime, xWaitTimeBetweenTicks, NULL, NULL, 0 ); + configASSERT( bSuccess ); while( xPortRunning == pdTRUE ) {