1
0
mirror of https://github.com/FreeRTOS/FreeRTOS-Kernel.git synced 2025-10-20 04:24:21 +08:00

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

View File

@@ -152,6 +152,7 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
TickType_t xWaitTimeBetweenTicks = portTICK_PERIOD_MS; TickType_t xWaitTimeBetweenTicks = portTICK_PERIOD_MS;
HANDLE hTimer = NULL; HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime; LARGE_INTEGER liDueTime;
BOOL bSuccess;
/* Set the timer resolution to the maximum possible. */ /* Set the timer resolution to the maximum possible. */
if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR ) 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 /* Set the Waitable Timer. The timer is set to run periodically at every
xWaitTimeBetweenTicks milliseconds. */ xWaitTimeBetweenTicks milliseconds. */
configASSERT( SetWaitableTimer( hTimer, &liDueTime, xWaitTimeBetweenTicks, NULL, NULL, 0 ) ); bSuccess = SetWaitableTimer( hTimer, &liDueTime, xWaitTimeBetweenTicks, NULL, NULL, 0 );
configASSERT( bSuccess );
while( xPortRunning == pdTRUE ) while( xPortRunning == pdTRUE )
{ {