Move temp variable declarations to top of functions

This commit is contained in:
bradleysmith23 2024-02-06 16:11:10 -08:00
parent f97dc8b20f
commit 86cf5f32f2
2 changed files with 8 additions and 4 deletions

View file

@ -316,6 +316,7 @@ typedef struct xLIST
/* The list item knows which list it is in. Obtain the list from the list \ /* The list item knows which list it is in. Obtain the list from the list \
* item. */ \ * item. */ \
List_t * const pxList = ( pxItemToRemove )->pxContainer; \ List_t * const pxList = ( pxItemToRemove )->pxContainer; \
UBaseType_t uxNumberOfItems; \
\ \
( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \ ( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \
( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \ ( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \
@ -326,7 +327,7 @@ typedef struct xLIST
} \ } \
\ \
( pxItemToRemove )->pxContainer = NULL; \ ( pxItemToRemove )->pxContainer = NULL; \
UBaseType_t uxNumberOfItems = ( pxList->uxNumberOfItems ); \ uxNumberOfItems = ( pxList->uxNumberOfItems ); \
uxNumberOfItems--; \ uxNumberOfItems--; \
( pxList->uxNumberOfItems ) = uxNumberOfItems; \ ( pxList->uxNumberOfItems ) = uxNumberOfItems; \
} while( 0 ) } while( 0 )
@ -356,6 +357,7 @@ typedef struct xLIST
#define listINSERT_END( pxList, pxNewListItem ) \ #define listINSERT_END( pxList, pxNewListItem ) \
do { \ do { \
ListItem_t * const pxIndex = ( pxList )->pxIndex; \ ListItem_t * const pxIndex = ( pxList )->pxIndex; \
UBaseType_t uxNumberOfitems; \
\ \
/* Only effective when configASSERT() is also defined, these tests may catch \ /* Only effective when configASSERT() is also defined, these tests may catch \
* the list data structures being overwritten in memory. They will not catch \ * the list data structures being overwritten in memory. They will not catch \
@ -375,7 +377,7 @@ typedef struct xLIST
/* Remember which list the item is in. */ \ /* Remember which list the item is in. */ \
( pxNewListItem )->pxContainer = ( pxList ); \ ( pxNewListItem )->pxContainer = ( pxList ); \
\ \
UBaseType_t uxNumberOfItems = ( ( pxList )->uxNumberOfItems ); \ uxNumberOfItems = ( ( pxList )->uxNumberOfItems ); \
uxNumberOfItems++; \ uxNumberOfItems++; \
( ( pxList )->uxNumberOfItems ) = uxNumberOfItems; \ ( ( pxList )->uxNumberOfItems ) = uxNumberOfItems; \
} while( 0 ) } while( 0 )

View file

@ -248,6 +248,7 @@
#define taskSWITCH_DELAYED_LISTS() \ #define taskSWITCH_DELAYED_LISTS() \
do { \ do { \
List_t * pxTemp; \ List_t * pxTemp; \
BaseType_t xCurrentOverflows; \
\ \
/* The delayed tasks list should be empty when the lists are switched. */ \ /* The delayed tasks list should be empty when the lists are switched. */ \
configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) ); \ configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) ); \
@ -255,7 +256,7 @@
pxTemp = pxDelayedTaskList; \ pxTemp = pxDelayedTaskList; \
pxDelayedTaskList = pxOverflowDelayedTaskList; \ pxDelayedTaskList = pxOverflowDelayedTaskList; \
pxOverflowDelayedTaskList = pxTemp; \ pxOverflowDelayedTaskList = pxTemp; \
BaseType_t xCurrentOverflows = xNumOfOverflows; \ xCurrentOverflows = xNumOfOverflows; \
xCurrentOverflows++; \ xCurrentOverflows++; \
xNumOfOverflows = xCurrentOverflows; \ xNumOfOverflows = xCurrentOverflows; \
prvResetNextTaskUnblockTime(); \ prvResetNextTaskUnblockTime(); \
@ -3800,6 +3801,7 @@ void vTaskSuspendAll( void )
#if ( configNUMBER_OF_CORES == 1 ) #if ( configNUMBER_OF_CORES == 1 )
{ {
UBaseType_t uxSchedulerSuspendedVal;
/* A critical section is not required as the variable is of type /* A critical section is not required as the variable is of type
* BaseType_t. Please read Richard Barry's reply in the following link to a * BaseType_t. Please read Richard Barry's reply in the following link to a
* post in the FreeRTOS support forum before reporting this as a bug! - * post in the FreeRTOS support forum before reporting this as a bug! -
@ -3811,7 +3813,7 @@ void vTaskSuspendAll( void )
/* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment /* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
* is used to allow calls to vTaskSuspendAll() to nest. */ * is used to allow calls to vTaskSuspendAll() to nest. */
UBaseType_t uxSchedulerSuspendedVal = uxSchedulerSuspended; uxSchedulerSuspendedVal = uxSchedulerSuspended;
uxSchedulerSuspendedVal++; uxSchedulerSuspendedVal++;
uxSchedulerSuspended = uxSchedulerSuspendedVal; uxSchedulerSuspended = uxSchedulerSuspendedVal;