From d5e9e57f73ee872ce30bac7028968d82142d5beb Mon Sep 17 00:00:00 2001 From: richardbarry Date: Mon, 1 Aug 2011 08:05:37 +0000 Subject: [PATCH] A few updates for coding standard reasons. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1527 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/tasks.c | 124 ++++++++++++++----------------------------------- 1 file changed, 35 insertions(+), 89 deletions(-) diff --git a/Source/tasks.c b/Source/tasks.c index 16914978c..a4e494612 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -146,8 +146,8 @@ PRIVILEGED_DATA static xList xPendingReadyList; /*< Tasks that have been r #if ( INCLUDE_vTaskDelete == 1 ) - PRIVILEGED_DATA static volatile xList xTasksWaitingTermination; /*< Tasks that have been deleted - but the their memory not yet freed. */ - PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTasksDeleted = ( unsigned portBASE_TYPE ) 0; + PRIVILEGED_DATA static xList xTasksWaitingTermination; /*< Tasks that have been deleted - but the their memory not yet freed. */ + PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTasksDeleted = ( unsigned portBASE_TYPE ) 0U; #endif @@ -164,16 +164,16 @@ PRIVILEGED_DATA static xList xPendingReadyList; /*< Tasks that have been r #endif /* File private variables. --------------------------------*/ -PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0; -PRIVILEGED_DATA static volatile portTickType xTickCount = ( portTickType ) 0; +PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0U; +PRIVILEGED_DATA static volatile portTickType xTickCount = ( portTickType ) 0U; PRIVILEGED_DATA static unsigned portBASE_TYPE uxTopUsedPriority = tskIDLE_PRIORITY; PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTopReadyPriority = tskIDLE_PRIORITY; PRIVILEGED_DATA static volatile signed portBASE_TYPE xSchedulerRunning = pdFALSE; PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxSchedulerSuspended = ( unsigned portBASE_TYPE ) pdFALSE; -PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxMissedTicks = ( unsigned portBASE_TYPE ) 0; +PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxMissedTicks = ( unsigned portBASE_TYPE ) 0U; PRIVILEGED_DATA static volatile portBASE_TYPE xMissedYield = ( portBASE_TYPE ) pdFALSE; PRIVILEGED_DATA static volatile portBASE_TYPE xNumOfOverflows = ( portBASE_TYPE ) 0; -PRIVILEGED_DATA static unsigned portBASE_TYPE uxTaskNumber = ( unsigned portBASE_TYPE ) 0; +PRIVILEGED_DATA static unsigned portBASE_TYPE uxTaskNumber = ( unsigned portBASE_TYPE ) 0U; PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType ) portMAX_DELAY; #if ( configGENERATE_RUN_TIME_STATS == 1 ) @@ -227,7 +227,7 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType ) #define vWriteTraceToBuffer() \ { \ - if( xTracing ) \ + if( xTracing != pdFALSE ) \ { \ if( uxPreviousTask != pxCurrentTCB->uxTCBNumber ) \ { \ @@ -319,7 +319,7 @@ portTickType xItemValue; \ vListRemove( &( pxTCB->xGenericListItem ) ); \ \ /* Is the task waiting on an event also? */ \ - if( pxTCB->xEventListItem.pvContainer ) \ + if( pxTCB->xEventListItem.pvContainer != NULL ) \ { \ vListRemove( &( pxTCB->xEventListItem ) ); \ } \ @@ -376,7 +376,7 @@ static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ); * This does not free memory allocated by the task itself (i.e. memory * allocated by calls to pvPortMalloc from within the tasks application code). */ -#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) ) +#if ( INCLUDE_vTaskDelete == 1 ) static void prvDeleteTCB( tskTCB *pxTCB ) PRIVILEGED_FUNCTION; @@ -455,7 +455,7 @@ tskTCB * pxNewTCB; #if( portUSING_MPU_WRAPPERS == 1 ) /* Should the task be created in privileged mode? */ portBASE_TYPE xRunPrivileged; - if( ( uxPriority & portPRIVILEGE_BIT ) != 0x00 ) + if( ( uxPriority & portPRIVILEGE_BIT ) != 0U ) { xRunPrivileged = pdTRUE; } @@ -623,7 +623,7 @@ tskTCB * pxNewTCB; vListRemove( &( pxTCB->xGenericListItem ) ); /* Is the task waiting on an event also? */ - if( pxTCB->xEventListItem.pvContainer ) + if( pxTCB->xEventListItem.pvContainer != NULL ) { vListRemove( &( pxTCB->xEventListItem ) ); } @@ -672,7 +672,7 @@ tskTCB * pxNewTCB; portBASE_TYPE xAlreadyYielded, xShouldDelay = pdFALSE; configASSERT( pxPreviousWakeTime ); - configASSERT( ( xTimeIncrement > 0 ) ); + configASSERT( ( xTimeIncrement > 0U ) ); vTaskSuspendAll(); { @@ -720,7 +720,7 @@ tskTCB * pxNewTCB; /* Force a reschedule if xTaskResumeAll has not already done so, we may have put ourselves to sleep. */ - if( !xAlreadyYielded ) + if( xAlreadyYielded == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -737,7 +737,7 @@ tskTCB * pxNewTCB; signed portBASE_TYPE xAlreadyYielded = pdFALSE; /* A delay time of zero just forces a reschedule. */ - if( xTicksToDelay > ( portTickType ) 0 ) + if( xTicksToDelay > ( portTickType ) 0U ) { vTaskSuspendAll(); { @@ -766,7 +766,7 @@ tskTCB * pxNewTCB; /* Force a reschedule if xTaskResumeAll has not already done so, we may have put ourselves to sleep. */ - if( !xAlreadyYielded ) + if( xAlreadyYielded == pdFALSE ) { portYIELD_WITHIN_API(); } @@ -929,7 +929,7 @@ tskTCB * pxNewTCB; vListRemove( &( pxTCB->xGenericListItem ) ); /* Is the task waiting on an event also? */ - if( pxTCB->xEventListItem.pvContainer ) + if( pxTCB->xEventListItem.pvContainer != NULL ) { vListRemove( &( pxTCB->xEventListItem ) ); } @@ -1131,7 +1131,7 @@ portBASE_TYPE xReturn; portDISABLE_INTERRUPTS(); xSchedulerRunning = pdTRUE; - xTickCount = ( portTickType ) 0; + xTickCount = ( portTickType ) 0U; /* If configGENERATE_RUN_TIME_STATS is defined then the following macro must be defined to configure the timer/counter used to generate @@ -1140,7 +1140,7 @@ portBASE_TYPE xReturn; /* Setting up the timer tick is hardware specific and thus in the portable interface. */ - if( xPortStartScheduler() ) + if( xPortStartScheduler() != pdFALSE ) { /* Should not reach here as if the scheduler is running the function will not return. */ @@ -1195,7 +1195,7 @@ signed portBASE_TYPE xAlreadyYielded = pdFALSE; if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) { - if( uxCurrentNumberOfTasks > ( unsigned portBASE_TYPE ) 0 ) + if( uxCurrentNumberOfTasks > ( unsigned portBASE_TYPE ) 0U ) { portBASE_TYPE xYieldRequired = pdFALSE; @@ -1219,9 +1219,9 @@ signed portBASE_TYPE xAlreadyYielded = pdFALSE; /* If any ticks occurred while the scheduler was suspended then they should be processed now. This ensures the tick count does not slip, and that any delayed tasks are resumed at the correct time. */ - if( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 ) + if( uxMissedTicks > ( unsigned portBASE_TYPE ) 0U ) { - while( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 ) + while( uxMissedTicks > ( unsigned portBASE_TYPE ) 0U ) { vTaskIncrementTick(); --uxMissedTicks; @@ -1352,7 +1352,7 @@ tskTCB *pxTCB; { if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE ) { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, tskDELETED_CHAR ); + prvListTaskWithinSingleList( pcWriteBuffer, &xTasksWaitingTermination, tskDELETED_CHAR ); } } #endif @@ -1361,7 +1361,7 @@ tskTCB *pxTCB; { if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, tskSUSPENDED_CHAR ); + prvListTaskWithinSingleList( pcWriteBuffer, &xSuspendedTaskList, tskSUSPENDED_CHAR ); } } #endif @@ -1427,7 +1427,7 @@ tskTCB *pxTCB; { if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE ) { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, ulTotalRunTime ); + prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, &xTasksWaitingTermination, ulTotalRunTime ); } } #endif @@ -1436,7 +1436,7 @@ tskTCB *pxTCB; { if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, ulTotalRunTime ); + prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, &xSuspendedTaskList, ulTotalRunTime ); } } #endif @@ -1502,7 +1502,6 @@ tskTCB *pxTCB; * documented in task.h *----------------------------------------------------------*/ - void vTaskIncrementTick( void ) { tskTCB * pxTCB; @@ -1513,7 +1512,7 @@ tskTCB * pxTCB; if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) { ++xTickCount; - if( xTickCount == ( portTickType ) 0 ) + if( xTickCount == ( portTickType ) 0U ) { xList *pxTemp; @@ -1578,59 +1577,6 @@ tskTCB * pxTCB; } /*-----------------------------------------------------------*/ -#if ( ( INCLUDE_vTaskCleanUpResources == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) - - void vTaskCleanUpResources( void ) - { - unsigned short usQueue; - volatile tskTCB *pxTCB; - - usQueue = ( unsigned short ) uxTopUsedPriority + ( unsigned short ) 1; - - /* Remove any TCB's from the ready queues. */ - do - { - usQueue--; - - while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ usQueue ] ) ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &( pxReadyTasksLists[ usQueue ] ) ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - }while( usQueue > ( unsigned short ) tskIDLE_PRIORITY ); - - /* Remove any TCB's from the delayed queue. */ - while( listLIST_IS_EMPTY( &xDelayedTaskList1 ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList1 ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - - /* Remove any TCB's from the overflow delayed queue. */ - while( listLIST_IS_EMPTY( &xDelayedTaskList2 ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList2 ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - - while( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xSuspendedTaskList ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - } - -#endif -/*-----------------------------------------------------------*/ - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction ) @@ -2076,7 +2022,7 @@ static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const #if ( portCRITICAL_NESTING_IN_TCB == 1 ) { - pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0; + pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0U; } #endif @@ -2164,7 +2110,7 @@ static void prvCheckTasksWaitingTermination( void ) /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called too often in the idle task. */ - if( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0 ) + if( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0U ) { vTaskSuspendAll(); xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination ); @@ -2241,7 +2187,7 @@ tskTCB *pxNewTCB; else { /* Just to help debugging. */ - memset( pxNewTCB->pxStack, tskSTACK_FILL_BYTE, usStackDepth * sizeof( portSTACK_TYPE ) ); + memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( portSTACK_TYPE ) ); } } @@ -2298,7 +2244,7 @@ tskTCB *pxNewTCB; if( ulTotalRunTime > 0UL ) { /* Has the task run at all? */ - if( pxNextTCB->ulRunTimeCounter == 0 ) + if( pxNextTCB->ulRunTimeCounter == 0UL ) { /* The task has used no CPU time at all. */ sprintf( pcStatsString, ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName ); @@ -2355,7 +2301,7 @@ tskTCB *pxNewTCB; static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) { - register unsigned short usCount = 0; + register unsigned short usCount = 0U; while( *pucStackByte == tskSTACK_FILL_BYTE ) { @@ -2399,7 +2345,7 @@ tskTCB *pxNewTCB; #endif /*-----------------------------------------------------------*/ -#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) ) +#if ( INCLUDE_vTaskDelete == 1 ) static void prvDeleteTCB( tskTCB *pxTCB ) { @@ -2475,7 +2421,7 @@ tskTCB *pxNewTCB; /* If the task being modified is in the ready state it will need to be moved in to a new list. */ - if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) ) + if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) { vListRemove( &( pxTCB->xGenericListItem ) ); @@ -2541,11 +2487,11 @@ void vTaskExitCritical( void ) { if( xSchedulerRunning != pdFALSE ) { - if( pxCurrentTCB->uxCriticalNesting > 0 ) + if( pxCurrentTCB->uxCriticalNesting > 0U ) { ( pxCurrentTCB->uxCriticalNesting )--; - if( pxCurrentTCB->uxCriticalNesting == 0 ) + if( pxCurrentTCB->uxCriticalNesting == 0U ) { portENABLE_INTERRUPTS(); } -- 2.39.5