From 910891f21d0c24fa7992b8d843e6b685d9a2ebc1 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Thu, 18 Apr 2024 08:42:13 +0000 Subject: [PATCH] Fix UBaseType_t conversion for increment and decrement operations --- include/list.h | 4 ++-- tasks.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/list.h b/include/list.h index 0de51bb5a..62a83a227 100644 --- a/include/list.h +++ b/include/list.h @@ -334,7 +334,7 @@ typedef struct xLIST } \ \ ( pxItemToRemove )->pxContainer = NULL; \ - ( ( pxList )->uxNumberOfItems ) -= ( UBaseType_t ) 1U; \ + ( ( pxList )->uxNumberOfItems ) = ( UBaseType_t ) ( ( ( pxList )->uxNumberOfItems ) - 1U ); \ } while( 0 ) /* @@ -381,7 +381,7 @@ typedef struct xLIST /* Remember which list the item is in. */ \ ( pxNewListItem )->pxContainer = ( pxList ); \ \ - ( ( pxList )->uxNumberOfItems ) += ( UBaseType_t ) 1U; \ + ( ( pxList )->uxNumberOfItems ) = ( UBaseType_t ) ( ( ( pxList )->uxNumberOfItems ) + 1U ); \ } while( 0 ) /* diff --git a/tasks.c b/tasks.c index 5cec846d0..1d473a78c 100644 --- a/tasks.c +++ b/tasks.c @@ -255,7 +255,7 @@ pxTemp = pxDelayedTaskList; \ pxDelayedTaskList = pxOverflowDelayedTaskList; \ pxOverflowDelayedTaskList = pxTemp; \ - xNumOfOverflows += ( BaseType_t ) 1; \ + xNumOfOverflows = ( BaseType_t )( xNumOfOverflows + 1 ); \ prvResetNextTaskUnblockTime(); \ } while( 0 ) @@ -2022,7 +2022,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, * updated. */ taskENTER_CRITICAL(); { - uxCurrentNumberOfTasks += ( UBaseType_t ) 1U; + uxCurrentNumberOfTasks = ( UBaseType_t ) ( uxCurrentNumberOfTasks + 1U ); if( pxCurrentTCB == NULL ) { @@ -3816,7 +3816,7 @@ void vTaskSuspendAll( void ) /* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment * is used to allow calls to vTaskSuspendAll() to nest. */ - uxSchedulerSuspended += ( UBaseType_t ) 1U; + uxSchedulerSuspended = ( UBaseType_t ) ( uxSchedulerSuspended + 1U ); /* Enforces ordering for ports and optimised compilers that may otherwise place * the above increment elsewhere. */ @@ -3969,7 +3969,7 @@ BaseType_t xTaskResumeAll( void ) * previous call to vTaskSuspendAll(). */ configASSERT( uxSchedulerSuspended != 0U ); - uxSchedulerSuspended -= ( UBaseType_t ) 1U; + uxSchedulerSuspended = ( UBaseType_t )( uxSchedulerSuspended - 1U ); portRELEASE_TASK_LOCK(); if( uxSchedulerSuspended == ( UBaseType_t ) 0U )