Skip to content

Commit d02ab77

Browse files
Fix warning issue for warning in arithmetic conversion for UBaseType_t (#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]>
1 parent dbef667 commit d02ab77

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

queue.c

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
490490
/* Check for multiplication overflow. */
491491
( ( SIZE_MAX / uxQueueLength ) >= uxItemSize ) &&
492492
/* Check for addition overflow. */
493-
( ( SIZE_MAX - sizeof( Queue_t ) ) >= ( uxQueueLength * uxItemSize ) ) )
493+
( ( UBaseType_t ) ( SIZE_MAX - sizeof( Queue_t ) ) >= ( uxQueueLength * uxItemSize ) ) )
494494
{
495495
/* Allocate enough space to hold the maximum number of items that
496496
* can be in the queue at any time. It is valid for uxItemSize to be
@@ -1329,7 +1329,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
13291329
* can be assumed there is no mutex holder and no need to determine if
13301330
* priority disinheritance is needed. Simply increase the count of
13311331
* messages (semaphores) available. */
1332-
pxQueue->uxMessagesWaiting = uxMessagesWaiting + ( UBaseType_t ) 1;
1332+
pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxMessagesWaiting + ( UBaseType_t ) 1 );
13331333

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

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

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

16361636
#if ( configUSE_MUTEXES == 1 )
16371637
{
@@ -2003,7 +2003,7 @@ BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
20032003
traceQUEUE_RECEIVE_FROM_ISR( pxQueue );
20042004

20052005
prvCopyDataFromQueue( pxQueue, pvBuffer );
2006-
pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1;
2006+
pxQueue->uxMessagesWaiting = ( UBaseType_t ) ( uxMessagesWaiting - ( UBaseType_t ) 1 );
20072007

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

21382138
taskENTER_CRITICAL();
21392139
{
2140-
uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting;
2140+
uxReturn = ( UBaseType_t ) ( pxQueue->uxLength - pxQueue->uxMessagesWaiting );
21412141
}
21422142
taskEXIT_CRITICAL();
21432143

@@ -2250,7 +2250,7 @@ UBaseType_t uxQueueGetQueueItemSize( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTI
22502250
* mutex. */
22512251
if( listCURRENT_LIST_LENGTH( &( pxQueue->xTasksWaitingToReceive ) ) > 0U )
22522252
{
2253-
uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) );
2253+
uxHighestPriorityOfWaitingTasks = ( UBaseType_t ) ( ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) listGET_ITEM_VALUE_OF_HEAD_ENTRY( &( pxQueue->xTasksWaitingToReceive ) ) );
22542254
}
22552255
else
22562256
{
@@ -2340,7 +2340,7 @@ static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue,
23402340
}
23412341
}
23422342

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

23452345
return xReturn;
23462346
}

stream_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
14481448

14491449
uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer )
14501450
{
1451-
return( xStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER );
1451+
return( ( uint8_t ) ( xStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) );
14521452
}
14531453

14541454
#endif /* configUSE_TRACE_FACILITY */

tasks.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,27 +3969,27 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
39693969
do
39703970
{
39713971
uxQueue--;
3972-
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady );
3972+
uxTask = ( UBaseType_t ) ( uxTask + prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ) );
39733973
} while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
39743974

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

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

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

0 commit comments

Comments
 (0)