Skip to content

Commit

Permalink
Fix warning issue for warning in arithmetic conversion for UBaseType_t (
Browse files Browse the repository at this point in the history
#720)

* Fix warning issue for warnign in arithmnetic conversion for UBaseType_t

* Fix warning in streamBuffer

* Add cast to queue.c file changes

* Minor fix to cast

* Fix formatting

* Revert minor fix to cast

---------

Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
  • Loading branch information
kar-rahul-aws and aggarg authored Jul 26, 2023
1 parent dbef667 commit d02ab77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions queue.c
100644 → 100755
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
/* Check for multiplication overflow. */ /* Check for multiplication overflow. */
( ( SIZE_MAX / uxQueueLength ) >= uxItemSize ) && ( ( SIZE_MAX / uxQueueLength ) >= uxItemSize ) &&
/* Check for addition overflow. */ /* Check for addition overflow. */
( ( SIZE_MAX - sizeof( Queue_t ) ) >= ( uxQueueLength * uxItemSize ) ) ) ( ( UBaseType_t ) ( SIZE_MAX - sizeof( Queue_t ) ) >= ( uxQueueLength * uxItemSize ) ) )
{ {
/* Allocate enough space to hold the maximum number of items that /* Allocate enough space to hold the maximum number of items that
* can be in the queue at any time. It is valid for uxItemSize to be * can be in the queue at any time. It is valid for uxItemSize to be
Expand Down Expand Up @@ -1329,7 +1329,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
* can be assumed there is no mutex holder and no need to determine if * can be assumed there is no mutex holder and no need to determine if
* priority disinheritance is needed. Simply increase the count of * priority disinheritance is needed. Simply increase the count of
* messages (semaphores) available. */ * messages (semaphores) available. */
pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1; pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxMessagesWaiting + ( UBaseType_t ) 1 );


/* The event list is not altered if the queue is locked. This will /* The event list is not altered if the queue is locked. This will
* be done when the queue is unlocked later. */ * be done when the queue is unlocked later. */
Expand Down Expand Up @@ -1474,7 +1474,7 @@ BaseType_t xQueueReceive( QueueHandle_t xQueue,
/* Data available, remove one item. */ /* Data available, remove one item. */
prvCopyDataFromQueue( pxQueue, pvBuffer ); prvCopyDataFromQueue( pxQueue, pvBuffer );
traceQUEUE_RECEIVE( pxQueue ); traceQUEUE_RECEIVE( pxQueue );
pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxMessagesWaiting - ( UBaseType_t ) 1 );


/* There is now space in the queue, were any tasks waiting to /* There is now space in the queue, were any tasks waiting to
* post to the queue? If so, unblock the highest priority waiting * post to the queue? If so, unblock the highest priority waiting
Expand Down Expand Up @@ -1631,7 +1631,7 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,


/* Semaphores are queues with a data size of zero and where the /* Semaphores are queues with a data size of zero and where the
* messages waiting is the semaphore's count. Reduce the count. */ * messages waiting is the semaphore's count. Reduce the count. */
pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1; pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxSemaphoreCount - ( UBaseType_t ) 1 );


#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{ {
Expand Down Expand Up @@ -2003,7 +2003,7 @@ BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
traceQUEUE_RECEIVE_FROM_ISR( pxQueue ); traceQUEUE_RECEIVE_FROM_ISR( pxQueue );


prvCopyDataFromQueue( pxQueue, pvBuffer ); prvCopyDataFromQueue( pxQueue, pvBuffer );
pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxMessagesWaiting - ( UBaseType_t ) 1 );


/* If the queue is locked the event list will not be modified. /* If the queue is locked the event list will not be modified.
* Instead update the lock count so the task that unlocks the queue * Instead update the lock count so the task that unlocks the queue
Expand Down Expand Up @@ -2137,7 +2137,7 @@ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )


taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting; uxReturn = ( UBaseType_t ) ( pxQueue->uxLength - pxQueue->uxMessagesWaiting );
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();


Expand Down Expand Up @@ -2250,7 +2250,7 @@ UBaseType_t uxQueueGetQueueItemSize( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTI
* mutex. */ * mutex. */
if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U ) if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U )
{ {
uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) ); uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) ( ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) ) );
} }
else else
{ {
Expand Down Expand Up @@ -2340,7 +2340,7 @@ static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue,
} }
} }


pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1; pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxMessagesWaiting + ( UBaseType_t ) 1 );


return xReturn; return xReturn;
} }
Expand Down
2 changes: 1 addition & 1 deletion stream_buffer.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,


uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer )
{ {
return( xStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ); return( ( uint8_t ) ( xStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) );
} }


#endif /* configUSE_TRACE_FACILITY */ #endif /* configUSE_TRACE_FACILITY */
Expand Down
10 changes: 5 additions & 5 deletions tasks.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3969,27 +3969,27 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
do do
{ {
uxQueue--; uxQueue--;
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ); uxTask = ( UBaseType_t ) ( uxTask + prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ) );
} while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */


/* Fill in an TaskStatus_t structure with information on each /* Fill in an TaskStatus_t structure with information on each
* task in the Blocked state. */ * task in the Blocked state. */
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked ); uxTask = ( UBaseType_t ) ( uxTask + prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked ) );
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked ); uxTask = ( UBaseType_t ) ( uxTask + prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked ) );


#if ( INCLUDE_vTaskDelete == 1 ) #if ( INCLUDE_vTaskDelete == 1 )
{ {
/* Fill in an TaskStatus_t structure with information on /* Fill in an TaskStatus_t structure with information on
* each task that has been deleted but not yet cleaned up. */ * each task that has been deleted but not yet cleaned up. */
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted ); uxTask = ( UBaseType_t ) ( uxTask + prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted ) );
} }
#endif #endif


#if ( INCLUDE_vTaskSuspend == 1 ) #if ( INCLUDE_vTaskSuspend == 1 )
{ {
/* Fill in an TaskStatus_t structure with information on /* Fill in an TaskStatus_t structure with information on
* each task in the Suspended state. */ * each task in the Suspended state. */
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended ); uxTask = ( UBaseType_t ) ( uxTask + prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended ) );
} }
#endif #endif


Expand Down

0 comments on commit d02ab77

Please sign in to comment.