Skip to content

Commit 76d4d8d

Browse files
committed
Code review suggestions
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent abef464 commit 76d4d8d

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

include/stack_macros.h

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,20 @@
8888

8989
#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )
9090

91-
#define taskCHECK_FOR_STACK_OVERFLOW() \
92-
do { \
93-
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
94-
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
95-
\
96-
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
97-
if( ( pulStack[ 0 ] != ulCheckValue ) || \
98-
( pulStack[ 1 ] != ulCheckValue ) || \
99-
( pulStack[ 2 ] != ulCheckValue ) || \
100-
( pulStack[ 3 ] != ulCheckValue ) ) \
101-
{ \
102-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
103-
} \
104-
\
105-
/* Is the currently saved stack pointer within the stack limit? */ \
106-
if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \
107-
{ \
108-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
109-
} \
91+
#define taskCHECK_FOR_STACK_OVERFLOW() \
92+
do { \
93+
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
94+
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
95+
\
96+
if( ( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) || \
97+
( pulStack[ 0 ] != ulCheckValue ) || \
98+
( pulStack[ 1 ] != ulCheckValue ) || \
99+
( pulStack[ 2 ] != ulCheckValue ) || \
100+
( pulStack[ 3 ] != ulCheckValue ) ) \
101+
{ \
102+
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
103+
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
104+
} \
110105
} while( 0 )
111106

112107
#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
@@ -126,16 +121,10 @@
126121
\
127122
pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
128123
\
129-
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
130-
/* Has the extremity of the task stack ever been written over? */ \
131-
if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
132-
{ \
133-
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
134-
} \
135-
\
136-
/* Is the currently saved stack pointer within the stack limit? */ \
137-
if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \
124+
if( ( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \
125+
( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) ) \
138126
{ \
127+
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
139128
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
140129
} \
141130
} while( 0 )

0 commit comments

Comments
 (0)