mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-05-12 11:42:57 -04:00
Fix undefined behavior from signed left-shift in MSVC-MingW port
Replace `( 1 << n )` with `( 1UL << n )` in all left-shift expressions in portable/MSVC-MingW/port.c. Shifting a signed int by >= 31 is undefined behavior per ISO C11 §6.5.7.
This commit is contained in:
parent
d1f551e253
commit
f8599deaf2
1 changed files with 5 additions and 5 deletions
|
|
@ -408,7 +408,7 @@ static void prvProcessSimulatedInterrupts( void )
|
||||||
|
|
||||||
/* Create a pending tick to ensure the first task is started as soon as
|
/* Create a pending tick to ensure the first task is started as soon as
|
||||||
* this thread pends. */
|
* this thread pends. */
|
||||||
ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK );
|
ulPendingInterrupts |= ( 1UL << portINTERRUPT_TICK );
|
||||||
SetEvent( pvInterruptEvent );
|
SetEvent( pvInterruptEvent );
|
||||||
|
|
||||||
while( xPortRunning == pdTRUE )
|
while( xPortRunning == pdTRUE )
|
||||||
|
|
@ -447,7 +447,7 @@ static void prvProcessSimulatedInterrupts( void )
|
||||||
if( ulIsrHandler[ i ]() != pdFALSE )
|
if( ulIsrHandler[ i ]() != pdFALSE )
|
||||||
{
|
{
|
||||||
/* A bit mask is used purely to help debugging. */
|
/* A bit mask is used purely to help debugging. */
|
||||||
ulSwitchRequired |= ( 1 << i );
|
ulSwitchRequired |= ( 1UL << i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,7 +580,7 @@ void vPortCloseRunningThread( void * pvTaskToDelete,
|
||||||
if( pvInterruptEventMutex != NULL )
|
if( pvInterruptEventMutex != NULL )
|
||||||
{
|
{
|
||||||
WaitForSingleObject( pvInterruptEventMutex, INFINITE );
|
WaitForSingleObject( pvInterruptEventMutex, INFINITE );
|
||||||
ulPendingInterrupts |= ( 1 << portINTERRUPT_YIELD );
|
ulPendingInterrupts |= ( 1UL << portINTERRUPT_YIELD );
|
||||||
ReleaseMutex( pvInterruptEventMutex );
|
ReleaseMutex( pvInterruptEventMutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -604,7 +604,7 @@ void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber )
|
||||||
if( ( ulInterruptNumber < portMAX_INTERRUPTS ) && ( pvInterruptEventMutex != NULL ) )
|
if( ( ulInterruptNumber < portMAX_INTERRUPTS ) && ( pvInterruptEventMutex != NULL ) )
|
||||||
{
|
{
|
||||||
WaitForSingleObject( pvInterruptEventMutex, INFINITE );
|
WaitForSingleObject( pvInterruptEventMutex, INFINITE );
|
||||||
ulPendingInterrupts |= ( 1 << ulInterruptNumber );
|
ulPendingInterrupts |= ( 1UL << ulInterruptNumber );
|
||||||
|
|
||||||
/* The simulated interrupt is now held pending, but don't actually
|
/* The simulated interrupt is now held pending, but don't actually
|
||||||
* process it yet if this call is within a critical section. It is
|
* process it yet if this call is within a critical section. It is
|
||||||
|
|
@ -645,7 +645,7 @@ void vPortGenerateSimulatedInterruptFromWindowsThread( uint32_t ulInterruptNumbe
|
||||||
|
|
||||||
/* Pending a user defined interrupt to be handled in simulated interrupt
|
/* Pending a user defined interrupt to be handled in simulated interrupt
|
||||||
* handler thread. */
|
* handler thread. */
|
||||||
ulPendingInterrupts |= ( 1 << ulInterruptNumber );
|
ulPendingInterrupts |= ( 1UL << ulInterruptNumber );
|
||||||
|
|
||||||
/* The interrupt is now pending - notify the simulated interrupt
|
/* The interrupt is now pending - notify the simulated interrupt
|
||||||
* handler thread. Must be outside of a critical section to get here so
|
* handler thread. Must be outside of a critical section to get here so
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue