Fix MISRA C 2012 Rule 13.3 Violations (#988)
* MISRA Rule 13.3 Fixes
* Add semiicolons that were accidentally removed
* Add parentheses back around pxList->uxNumberOfItems where removed.
* Formatting fix
* Add Casts to UBaseType_t
---------
Co-authored-by: bjbsmith <bjbsmith@uafeb6a6bcdce55.ant.amazon.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
diff --git a/include/list.h b/include/list.h
index 7084834..9b96ab1 100644
--- a/include/list.h
+++ b/include/list.h
@@ -326,7 +326,7 @@
} \
\
( pxItemToRemove )->pxContainer = NULL; \
- ( pxList->uxNumberOfItems )--; \
+ ( ( pxList )->uxNumberOfItems ) -= ( UBaseType_t ) 1U; \
} while( 0 )
/*
@@ -363,17 +363,17 @@
\
/* Insert a new list item into ( pxList ), but rather than sort the list, \
* makes the new list item the last item to be removed by a call to \
- * listGET_OWNER_OF_NEXT_ENTRY(). */ \
- ( pxNewListItem )->pxNext = pxIndex; \
- ( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
- \
- pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
- pxIndex->pxPrevious = ( pxNewListItem ); \
- \
- /* Remember which list the item is in. */ \
- ( pxNewListItem )->pxContainer = ( pxList ); \
- \
- ( ( pxList )->uxNumberOfItems )++; \
+ * listGET_OWNER_OF_NEXT_ENTRY(). */ \
+ ( pxNewListItem )->pxNext = pxIndex; \
+ ( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
+ \
+ pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
+ pxIndex->pxPrevious = ( pxNewListItem ); \
+ \
+ /* Remember which list the item is in. */ \
+ ( pxNewListItem )->pxContainer = ( pxList ); \
+ \
+ ( ( pxList )->uxNumberOfItems ) += ( UBaseType_t ) 1U; \
} while( 0 )
/*
diff --git a/list.c b/list.c
index 9073008..0ac5b04 100644
--- a/list.c
+++ b/list.c
@@ -130,7 +130,7 @@
/* Remember which list the item is in. */
pxNewListItem->pxContainer = pxList;
- ( pxList->uxNumberOfItems )++;
+ ( pxList->uxNumberOfItems ) += ( UBaseType_t ) 1U;
traceRETURN_vListInsertEnd();
}
@@ -205,12 +205,13 @@
* item later. */
pxNewListItem->pxContainer = pxList;
- ( pxList->uxNumberOfItems )++;
+ ( pxList->uxNumberOfItems ) += ( UBaseType_t ) 1U;
traceRETURN_vListInsert();
}
/*-----------------------------------------------------------*/
+
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
{
/* The list item knows which list it is in. Obtain the list from the list
@@ -219,8 +220,6 @@
traceENTER_uxListRemove( pxItemToRemove );
-
-
pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
@@ -238,7 +237,7 @@
}
pxItemToRemove->pxContainer = NULL;
- ( pxList->uxNumberOfItems )--;
+ ( pxList->uxNumberOfItems ) -= ( UBaseType_t ) 1U;
traceRETURN_uxListRemove( pxList->uxNumberOfItems );
diff --git a/tasks.c b/tasks.c
index 95f60b1..c51c155 100644
--- a/tasks.c
+++ b/tasks.c
@@ -255,7 +255,7 @@
pxTemp = pxDelayedTaskList; \
pxDelayedTaskList = pxOverflowDelayedTaskList; \
pxOverflowDelayedTaskList = pxTemp; \
- xNumOfOverflows++; \
+ xNumOfOverflows += ( BaseType_t ) 1; \
prvResetNextTaskUnblockTime(); \
} while( 0 )
@@ -2021,7 +2021,7 @@
* updated. */
taskENTER_CRITICAL();
{
- uxCurrentNumberOfTasks++;
+ uxCurrentNumberOfTasks += ( UBaseType_t ) 1U;
if( pxCurrentTCB == NULL )
{
@@ -3815,7 +3815,7 @@
/* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
* is used to allow calls to vTaskSuspendAll() to nest. */
- ++uxSchedulerSuspended;
+ uxSchedulerSuspended += ( UBaseType_t ) 1U;
/* Enforces ordering for ports and optimised compilers that may otherwise place
* the above increment elsewhere. */
@@ -3968,7 +3968,7 @@
* previous call to vTaskSuspendAll(). */
configASSERT( uxSchedulerSuspended != 0U );
- --uxSchedulerSuspended;
+ uxSchedulerSuspended -= ( UBaseType_t ) 1U;
portRELEASE_TASK_LOCK();
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
@@ -4968,7 +4968,7 @@
}
else
{
- ++xPendedTicks;
+ xPendedTicks += 1U;
/* The tick hook gets called at regular intervals, even if the
* scheduler is locked. */