Skip to content

Commit

Permalink
Fix MISRA 2012 rule 10.4 violations (#852)
Browse files Browse the repository at this point in the history
Fix MISRA 2012 rule 10.4 violations
  • Loading branch information
chinglee-iot authored Nov 28, 2023
1 parent ce88ade commit 1813a45
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* should not be provided if the item size is 0. */
( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ) &&
( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ) )
( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0U ) ) ) &&
( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0U ) ) ) )
{
#if ( configASSERT_DEFINED == 1 )
{
Expand Down Expand Up @@ -864,7 +864,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,

traceENTER_xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );

if( ( uxMaxCount != 0 ) &&
if( ( uxMaxCount != 0U ) &&
( uxInitialCount <= uxMaxCount ) )
{
xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
Expand Down Expand Up @@ -903,7 +903,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,

traceENTER_xQueueCreateCountingSemaphore( uxMaxCount, uxInitialCount );

if( ( uxMaxCount != 0 ) &&
if( ( uxMaxCount != 0U ) &&
( uxInitialCount <= uxMaxCount ) )
{
xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
Expand Down
2 changes: 1 addition & 1 deletion stream_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
* this is a quirk of the implementation that means otherwise the free
* space would be reported as one byte smaller than would be logically
* expected. */
if( xBufferSizeBytes < ( xBufferSizeBytes + 1 + sizeof( StreamBuffer_t ) ) )
if( xBufferSizeBytes < ( xBufferSizeBytes + 1U + sizeof( StreamBuffer_t ) ) )
{
xBufferSizeBytes++;
pvAllocatedMemory = pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) );
Expand Down
34 changes: 17 additions & 17 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;

#if ( configRUN_MULTIPLE_PRIORITIES == 0 )
/* 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 ) )
{
configASSERT( ( xYieldPendings[ portGET_CORE_ID() ] == pdTRUE ) ||
Expand Down Expand Up @@ -1044,7 +1044,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
* idle tasks, not user tasks at the idle priority. */
if( uxCurrentPriority < uxTopReadyPriority )
{
if( ( pxTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0 )
if( ( pxTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0U )
{
continue;
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;

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 );
}
Expand Down Expand Up @@ -1854,7 +1854,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,

/* Ensure the name string is terminated in the case that the string length
* 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
{
Expand Down Expand Up @@ -2165,7 +2165,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
* large to hold the generated string. Return the
* number of characters actually written without
* counting the terminating NULL character. */
uxCharsWritten = n - 1;
uxCharsWritten = n - 1U;
}
else
{
Expand Down Expand Up @@ -3873,7 +3873,7 @@ void vTaskSuspendAll( void )
{
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
* time slicing is used then the very next tick interrupt must be
Expand Down Expand Up @@ -4813,7 +4813,7 @@ BaseType_t xTaskIncrementTick( void )
{
#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;
}
Expand All @@ -4828,7 +4828,7 @@ BaseType_t xTaskIncrementTick( void )

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;
}
Expand Down Expand Up @@ -5807,7 +5807,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
* valid. */
xExpectedIdleTime = prvGetExpectedIdleTime();

if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP )
if( xExpectedIdleTime >= ( TickType_t ) configEXPECTED_IDLE_TIME_BEFORE_SLEEP )
{
vTaskSuspendAll();
{
Expand All @@ -5822,7 +5822,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
* portSUPPRESS_TICKS_AND_SLEEP() to be called. */
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();
portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );
Expand Down Expand Up @@ -5874,7 +5874,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )

/* 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. */
eReturn = eAbortSleep;
Expand All @@ -5884,7 +5884,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
/* A yield was pended while the scheduler was suspended. */
eReturn = eAbortSleep;
}
else if( xPendedTicks != 0 )
else if( xPendedTicks != 0U )
{
/* A tick interrupt has already occurred but was held pending
* because the scheduler is suspended. */
Expand Down Expand Up @@ -6898,7 +6898,7 @@ static void prvResetNextTaskUnblockTime( void )
* interrupt. Only assert if the critical nesting count is 1 to
* protect against recursive calls if the assert function also uses a
* critical section. */
if( pxCurrentTCB->uxCriticalNesting == 1 )
if( pxCurrentTCB->uxCriticalNesting == 1U )
{
portASSERT_IF_IN_ISR();
}
Expand Down Expand Up @@ -7269,13 +7269,13 @@ static void prvResetNextTaskUnblockTime( void )
* can be printed in tabular form more easily. */
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* 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
* writes a terminating null character. So we are essentially
* checking if the buffer has space to write at least one non-null
* character. */
if( uxConsumedBufferLength < ( uxBufferLength - 1 ) )
if( uxConsumedBufferLength < ( uxBufferLength - 1U ) )
{
/* Write the rest of the string. */
#if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
Expand Down Expand Up @@ -7411,13 +7411,13 @@ static void prvResetNextTaskUnblockTime( void )
* easily. */
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* 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
* writes a terminating null character. So we are essentially
* checking if the buffer has space to write at least one non-null
* character. */
if( uxConsumedBufferLength < ( uxBufferLength - 1 ) )
if( uxConsumedBufferLength < ( uxBufferLength - 1U ) )
{
if( ulStatsAsPercentage > 0UL )
{
Expand Down
10 changes: 5 additions & 5 deletions timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
configASSERT( xTimer );
taskENTER_CRITICAL();
{
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0 )
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0U )
{
/* Not an auto-reload timer. */
xReturn = pdFALSE;
Expand Down Expand Up @@ -662,7 +662,7 @@

configASSERT( ppxTimerBuffer != NULL );

if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) != 0 )
if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) != 0U )
{
*ppxTimerBuffer = ( StaticTimer_t * ) pxTimer;
xReturn = pdTRUE;
Expand Down Expand Up @@ -724,7 +724,7 @@

/* 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. */
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 )
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0U )
{
prvReloadTimer( pxTimer, xNextExpireTime, xTimeNow );
}
Expand Down Expand Up @@ -1001,7 +1001,7 @@
{
/* The timer expired before it was added to the active
* 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 );
}
Expand Down Expand Up @@ -1165,7 +1165,7 @@
/* Is the timer in the list of active timers? */
taskENTER_CRITICAL();
{
if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0 )
if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0U )
{
xReturn = pdFALSE;
}
Expand Down

0 comments on commit 1813a45

Please sign in to comment.