Explicit casting added to the 'check for time out' function to ensure integer promotion does not occur.

This commit is contained in:
Richard Barry 2009-07-25 18:10:16 +00:00
parent af6c245366
commit 87eb48c97c

View file

@ -3,14 +3,14 @@
This file is part of the FreeRTOS distribution. This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation and modified by the FreeRTOS exception. Free Software Foundation and modified by the FreeRTOS exception.
**NOTE** The exception to the GPL is included to allow you to distribute a **NOTE** The exception to the GPL is included to allow you to distribute a
combined work that includes FreeRTOS without being obliged to provide the combined work that includes FreeRTOS without being obliged to provide the
source code for proprietary components outside of the FreeRTOS kernel. source code for proprietary components outside of the FreeRTOS kernel.
Alternative commercial license and support terms are also available upon Alternative commercial license and support terms are also available upon
request. See the licensing section of http://www.FreeRTOS.org for full request. See the licensing section of http://www.FreeRTOS.org for full
license details. license details.
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
@ -387,7 +387,7 @@ tskTCB * pxNewTCB;
required by the port. */ required by the port. */
#if portSTACK_GROWTH < 0 #if portSTACK_GROWTH < 0
{ {
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ) - ( ( usStackDepth - 1 ) % portBYTE_ALIGNMENT ); pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ) - ( ( usStackDepth - 1 ) % portBYTE_ALIGNMENT );
} }
#else #else
{ {
@ -528,8 +528,8 @@ tskTCB * pxNewTCB;
/* Increment the uxTaskNumberVariable also so kernel aware debuggers /* Increment the uxTaskNumberVariable also so kernel aware debuggers
can detect that the task lists need re-generating. */ can detect that the task lists need re-generating. */
uxTaskNumber++; uxTaskNumber++;
traceTASK_DELETE( pxTCB ); traceTASK_DELETE( pxTCB );
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
@ -1469,7 +1469,7 @@ void vTaskIncrementTick( void )
portENTER_CRITICAL(); portENTER_CRITICAL();
xReturn = xTCB->pxTaskTag; xReturn = xTCB->pxTaskTag;
portEXIT_CRITICAL(); portEXIT_CRITICAL();
return xReturn; return xReturn;
} }
@ -1693,7 +1693,7 @@ portBASE_TYPE xReturn;
else /* We are not blocking indefinitely, perform the checks below. */ else /* We are not blocking indefinitely, perform the checks below. */
#endif #endif
if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xTickCount >= pxTimeOut->xTimeOnEntering ) ) if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( ( portTickType ) xTickCount >= ( portTickType ) pxTimeOut->xTimeOnEntering ) )
{ {
/* The tick count is greater than the time at which vTaskSetTimeout() /* The tick count is greater than the time at which vTaskSetTimeout()
was called, but has also overflowed since vTaskSetTimeOut() was called. was called, but has also overflowed since vTaskSetTimeOut() was called.
@ -1701,10 +1701,10 @@ portBASE_TYPE xReturn;
passed since vTaskSetTimeout() was called. */ passed since vTaskSetTimeout() was called. */
xReturn = pdTRUE; xReturn = pdTRUE;
} }
else if( ( xTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait ) else if( ( ( portTickType ) xTickCount - ( portTickType ) pxTimeOut->xTimeOnEntering ) < ( portTickType ) *pxTicksToWait )
{ {
/* Not a genuine timeout. Adjust parameters for time remaining. */ /* Not a genuine timeout. Adjust parameters for time remaining. */
*pxTicksToWait -= ( xTickCount - pxTimeOut->xTimeOnEntering ); *pxTicksToWait -= ( ( portTickType ) xTickCount - ( portTickType ) pxTimeOut->xTimeOnEntering );
vTaskSetTimeOutState( pxTimeOut ); vTaskSetTimeOutState( pxTimeOut );
xReturn = pdFALSE; xReturn = pdFALSE;
} }