Skip to content

Fix too small return type for uxTaskGetStackHighWaterMark() #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
/* Set the stack pointer type to be uint16_t, otherwise it defaults to unsigned long */
#define portPOINTER_SIZE_TYPE uint16_t

/* Set the stack depth type to be uint16_t. */
#define configSTACK_DEPTH_TYPE uint16_t

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

Expand Down
4 changes: 2 additions & 2 deletions src/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ typedef struct xTASK_PARAMETERS
{
TaskFunction_t pvTaskCode;
const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
uint16_t usStackDepth;
configSTACK_DEPTH_TYPE usStackDepth;
void *pvParameters;
UBaseType_t uxPriority;
StackType_t *puxStackBuffer;
Expand Down Expand Up @@ -1420,7 +1420,7 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
* actual spaces on the stack rather than bytes) since the task referenced by
* xTask was created.
*/
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;

/* When using trace macros it is sometimes necessary to include task.h before
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
Expand Down
14 changes: 7 additions & 7 deletions src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;

prvInitialiseNewTask( pxTaskDefinition->pvTaskCode,
pxTaskDefinition->pcName,
( uint32_t ) pxTaskDefinition->usStackDepth,
pxTaskDefinition->usStackDepth,
pxTaskDefinition->pvParameters,
pxTaskDefinition->uxPriority,
pxCreatedTask, pxNewTCB,
Expand Down Expand Up @@ -706,7 +706,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB ) PRIVILEGED_FUNCTION;

prvInitialiseNewTask( pxTaskDefinition->pvTaskCode,
pxTaskDefinition->pcName,
( uint32_t ) pxTaskDefinition->usStackDepth,
pxTaskDefinition->usStackDepth,
pxTaskDefinition->pvParameters,
pxTaskDefinition->uxPriority,
pxCreatedTask, pxNewTCB,
Expand Down Expand Up @@ -3622,7 +3622,7 @@ static void prvCheckTasksWaitingTermination( void )

#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )

static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )
static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )
{
uint32_t ulCount = 0U;

Expand All @@ -3634,19 +3634,19 @@ static void prvCheckTasksWaitingTermination( void )

ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */

return ( uint16_t ) ulCount;
return ( configSTACK_DEPTH_TYPE ) ulCount;
}

#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )

UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask )
configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark( TaskHandle_t xTask )
{
TCB_t *pxTCB;
uint8_t *pucEndOfStack;
UBaseType_t uxReturn;
configSTACK_DEPTH_TYPE uxReturn;

pxTCB = prvGetTCBFromHandle( xTask );

Expand All @@ -3660,7 +3660,7 @@ static void prvCheckTasksWaitingTermination( void )
}
#endif

uxReturn = ( UBaseType_t ) prvTaskCheckFreeStackSpace( pucEndOfStack );
uxReturn = prvTaskCheckFreeStackSpace( pucEndOfStack );

return uxReturn;
}
Expand Down