Skip to content

Commit ccabdec

Browse files
authored
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).
1 parent 386c1bc commit ccabdec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

portable/MSVC-MingW/port.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
152152
TickType_t xWaitTimeBetweenTicks = portTICK_PERIOD_MS;
153153
HANDLE hTimer = NULL;
154154
LARGE_INTEGER liDueTime;
155+
BOOL bSuccess;
155156

156157
/* Set the timer resolution to the maximum possible. */
157158
if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR )
@@ -190,7 +191,8 @@ static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
190191

191192
/* Set the Waitable Timer. The timer is set to run periodically at every
192193
xWaitTimeBetweenTicks milliseconds. */
193-
configASSERT( SetWaitableTimer( hTimer, &liDueTime, xWaitTimeBetweenTicks, NULL, NULL, 0 ) );
194+
bSuccess = SetWaitableTimer( hTimer, &liDueTime, xWaitTimeBetweenTicks, NULL, NULL, 0 );
195+
configASSERT( bSuccess );
194196

195197
while( xPortRunning == pdTRUE )
196198
{

0 commit comments

Comments
 (0)