Fix MISRA 2012 rule 10.4 violations (#852)

Fix MISRA 2012 rule 10.4 violations
pull/853/head^2
chinglee-iot 1 year ago committed by GitHub
parent ce88adea2a
commit 1813a4551e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -389,8 +389,8 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
/* A queue storage area should be provided if the item size is not 0, and /* A queue storage area should be provided if the item size is not 0, and
* should not be provided if the item size is 0. */ * should not be provided if the item size is 0. */
( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ) && ( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0U ) ) ) &&
( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ) ) ( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0U ) ) ) )
{ {
#if ( configASSERT_DEFINED == 1 ) #if ( configASSERT_DEFINED == 1 )
{ {
@ -864,7 +864,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,
traceENTER_xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue ); traceENTER_xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
if( ( uxMaxCount != 0 ) && if( ( uxMaxCount != 0U ) &&
( uxInitialCount <= uxMaxCount ) ) ( uxInitialCount <= uxMaxCount ) )
{ {
xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
@ -903,7 +903,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,
traceENTER_xQueueCreateCountingSemaphore( uxMaxCount, uxInitialCount ); traceENTER_xQueueCreateCountingSemaphore( uxMaxCount, uxInitialCount );
if( ( uxMaxCount != 0 ) && if( ( uxMaxCount != 0U ) &&
( uxInitialCount <= uxMaxCount ) ) ( uxInitialCount <= uxMaxCount ) )
{ {
xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );

@ -362,7 +362,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
* this is a quirk of the implementation that means otherwise the free * this is a quirk of the implementation that means otherwise the free
* space would be reported as one byte smaller than would be logically * space would be reported as one byte smaller than would be logically
* expected. */ * expected. */
if( xBufferSizeBytes < ( xBufferSizeBytes + 1 + sizeof( StreamBuffer_t ) ) ) if( xBufferSizeBytes < ( xBufferSizeBytes + 1U + sizeof( StreamBuffer_t ) ) )
{ {
xBufferSizeBytes++; xBufferSizeBytes++;
pvAllocatedMemory = pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) ); pvAllocatedMemory = pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) );

@ -962,7 +962,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
#if ( configRUN_MULTIPLE_PRIORITIES == 0 ) #if ( configRUN_MULTIPLE_PRIORITIES == 0 )
/* Verify that the calling core always yields to higher priority tasks. */ /* Verify that the calling core always yields to higher priority tasks. */
if( ( ( pxCurrentTCBs[ portGET_CORE_ID() ]->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0 ) && if( ( ( pxCurrentTCBs[ portGET_CORE_ID() ]->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0U ) &&
( pxTCB->uxPriority > pxCurrentTCBs[ portGET_CORE_ID() ]->uxPriority ) ) ( pxTCB->uxPriority > pxCurrentTCBs[ portGET_CORE_ID() ]->uxPriority ) )
{ {
configASSERT( ( xYieldPendings[ portGET_CORE_ID() ] == pdTRUE ) || configASSERT( ( xYieldPendings[ portGET_CORE_ID() ] == pdTRUE ) ||
@ -1044,7 +1044,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
* idle tasks, not user tasks at the idle priority. */ * idle tasks, not user tasks at the idle priority. */
if( uxCurrentPriority < uxTopReadyPriority ) if( uxCurrentPriority < uxTopReadyPriority )
{ {
if( ( pxTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0 ) if( ( pxTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0U )
{ {
continue; continue;
} }
@ -1136,7 +1136,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
for( x = ( BaseType_t ) 0; x < ( BaseType_t ) configNUMBER_OF_CORES; x++ ) for( x = ( BaseType_t ) 0; x < ( BaseType_t ) configNUMBER_OF_CORES; x++ )
{ {
if( ( pxCurrentTCBs[ x ]->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) != 0 ) if( ( pxCurrentTCBs[ x ]->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) != 0U )
{ {
prvYieldCore( x ); prvYieldCore( x );
} }
@ -1854,7 +1854,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
/* Ensure the name string is terminated in the case that the string length /* Ensure the name string is terminated in the case that the string length
* was greater or equal to configMAX_TASK_NAME_LEN. */ * was greater or equal to configMAX_TASK_NAME_LEN. */
pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0'; pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1U ] = '\0';
} }
else else
{ {
@ -2165,7 +2165,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
* large to hold the generated string. Return the * large to hold the generated string. Return the
* number of characters actually written without * number of characters actually written without
* counting the terminating NULL character. */ * counting the terminating NULL character. */
uxCharsWritten = n - 1; uxCharsWritten = n - 1U;
} }
else else
{ {
@ -3873,7 +3873,7 @@ void vTaskSuspendAll( void )
{ {
xReturn = 0; xReturn = 0;
} }
else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 ) else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1U )
{ {
/* There are other idle priority tasks in the ready state. If /* There are other idle priority tasks in the ready state. If
* time slicing is used then the very next tick interrupt must be * time slicing is used then the very next tick interrupt must be
@ -4813,7 +4813,7 @@ BaseType_t xTaskIncrementTick( void )
{ {
#if ( configNUMBER_OF_CORES == 1 ) #if ( configNUMBER_OF_CORES == 1 )
{ {
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 ) if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > 1U )
{ {
xSwitchRequired = pdTRUE; xSwitchRequired = pdTRUE;
} }
@ -4828,7 +4828,7 @@ BaseType_t xTaskIncrementTick( void )
for( xCoreID = 0; xCoreID < ( ( BaseType_t ) configNUMBER_OF_CORES ); xCoreID++ ) for( xCoreID = 0; xCoreID < ( ( BaseType_t ) configNUMBER_OF_CORES ); xCoreID++ )
{ {
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCBs[ xCoreID ]->uxPriority ] ) ) > 1 ) if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCBs[ xCoreID ]->uxPriority ] ) ) > 1U )
{ {
xYieldRequiredForCore[ xCoreID ] = pdTRUE; xYieldRequiredForCore[ xCoreID ] = pdTRUE;
} }
@ -5807,7 +5807,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
* valid. */ * valid. */
xExpectedIdleTime = prvGetExpectedIdleTime(); xExpectedIdleTime = prvGetExpectedIdleTime();
if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) if( xExpectedIdleTime >= ( TickType_t ) configEXPECTED_IDLE_TIME_BEFORE_SLEEP )
{ {
vTaskSuspendAll(); vTaskSuspendAll();
{ {
@ -5822,7 +5822,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
* portSUPPRESS_TICKS_AND_SLEEP() to be called. */ * portSUPPRESS_TICKS_AND_SLEEP() to be called. */
configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( xExpectedIdleTime ); configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( xExpectedIdleTime );
if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) if( xExpectedIdleTime >= ( TickType_t ) configEXPECTED_IDLE_TIME_BEFORE_SLEEP )
{ {
traceLOW_POWER_IDLE_BEGIN(); traceLOW_POWER_IDLE_BEGIN();
portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ); portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );
@ -5874,7 +5874,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
/* This function must be called from a critical section. */ /* This function must be called from a critical section. */
if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 ) if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0U )
{ {
/* A task was made ready while the scheduler was suspended. */ /* A task was made ready while the scheduler was suspended. */
eReturn = eAbortSleep; eReturn = eAbortSleep;
@ -5884,7 +5884,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
/* A yield was pended while the scheduler was suspended. */ /* A yield was pended while the scheduler was suspended. */
eReturn = eAbortSleep; eReturn = eAbortSleep;
} }
else if( xPendedTicks != 0 ) else if( xPendedTicks != 0U )
{ {
/* A tick interrupt has already occurred but was held pending /* A tick interrupt has already occurred but was held pending
* because the scheduler is suspended. */ * because the scheduler is suspended. */
@ -6898,7 +6898,7 @@ static void prvResetNextTaskUnblockTime( void )
* interrupt. Only assert if the critical nesting count is 1 to * interrupt. Only assert if the critical nesting count is 1 to
* protect against recursive calls if the assert function also uses a * protect against recursive calls if the assert function also uses a
* critical section. */ * critical section. */
if( pxCurrentTCB->uxCriticalNesting == 1 ) if( pxCurrentTCB->uxCriticalNesting == 1U )
{ {
portASSERT_IF_IN_ISR(); portASSERT_IF_IN_ISR();
} }
@ -7269,13 +7269,13 @@ static void prvResetNextTaskUnblockTime( void )
* can be printed in tabular form more easily. */ * can be printed in tabular form more easily. */
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* Do not count the terminating null character. */ /* Do not count the terminating null character. */
uxConsumedBufferLength = uxConsumedBufferLength + ( configMAX_TASK_NAME_LEN - 1 ); uxConsumedBufferLength = uxConsumedBufferLength + ( configMAX_TASK_NAME_LEN - 1U );
/* Is there space left in the buffer? -1 is done because snprintf /* Is there space left in the buffer? -1 is done because snprintf
* writes a terminating null character. So we are essentially * writes a terminating null character. So we are essentially
* checking if the buffer has space to write at least one non-null * checking if the buffer has space to write at least one non-null
* character. */ * character. */
if( uxConsumedBufferLength < ( uxBufferLength - 1 ) ) if( uxConsumedBufferLength < ( uxBufferLength - 1U ) )
{ {
/* Write the rest of the string. */ /* Write the rest of the string. */
#if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
@ -7411,13 +7411,13 @@ static void prvResetNextTaskUnblockTime( void )
* easily. */ * easily. */
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* Do not count the terminating null character. */ /* Do not count the terminating null character. */
uxConsumedBufferLength = uxConsumedBufferLength + ( configMAX_TASK_NAME_LEN - 1 ); uxConsumedBufferLength = uxConsumedBufferLength + ( configMAX_TASK_NAME_LEN - 1U );
/* Is there space left in the buffer? -1 is done because snprintf /* Is there space left in the buffer? -1 is done because snprintf
* writes a terminating null character. So we are essentially * writes a terminating null character. So we are essentially
* checking if the buffer has space to write at least one non-null * checking if the buffer has space to write at least one non-null
* character. */ * character. */
if( uxConsumedBufferLength < ( uxBufferLength - 1 ) ) if( uxConsumedBufferLength < ( uxBufferLength - 1U ) )
{ {
if( ulStatsAsPercentage > 0UL ) if( ulStatsAsPercentage > 0UL )
{ {

@ -603,7 +603,7 @@
configASSERT( xTimer ); configASSERT( xTimer );
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0 ) if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0U )
{ {
/* Not an auto-reload timer. */ /* Not an auto-reload timer. */
xReturn = pdFALSE; xReturn = pdFALSE;
@ -662,7 +662,7 @@
configASSERT( ppxTimerBuffer != NULL ); configASSERT( ppxTimerBuffer != NULL );
if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) != 0 ) if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) != 0U )
{ {
*ppxTimerBuffer = ( StaticTimer_t * ) pxTimer; *ppxTimerBuffer = ( StaticTimer_t * ) pxTimer;
xReturn = pdTRUE; xReturn = pdTRUE;
@ -724,7 +724,7 @@
/* If the timer is an auto-reload timer then calculate the next /* If the timer is an auto-reload timer then calculate the next
* expiry time and re-insert the timer in the list of active timers. */ * expiry time and re-insert the timer in the list of active timers. */
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 ) if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0U )
{ {
prvReloadTimer( pxTimer, xNextExpireTime, xTimeNow ); prvReloadTimer( pxTimer, xNextExpireTime, xTimeNow );
} }
@ -1001,7 +1001,7 @@
{ {
/* The timer expired before it was added to the active /* The timer expired before it was added to the active
* timer list. Process it now. */ * timer list. Process it now. */
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 ) if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0U )
{ {
prvReloadTimer( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow ); prvReloadTimer( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow );
} }
@ -1165,7 +1165,7 @@
/* Is the timer in the list of active timers? */ /* Is the timer in the list of active timers? */
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0 ) if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0U )
{ {
xReturn = pdFALSE; xReturn = pdFALSE;
} }

Loading…
Cancel
Save