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).
This commit is contained in:
Kim Lindberg Schwaner 2025-08-15 20:09:28 +02:00 committed by GitHub
parent 386c1bca66
commit ccabdec2f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 )
{