Skip to content

Commit f37bcd5

Browse files
authored
Wrap macros in do { ... } while( 0 ) (#240)
1 parent ac2c383 commit f37bcd5

File tree

75 files changed

+79
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+79
-164
lines changed

.github/scripts/kernel_checker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
r'.*\.git.*',
3939
r'.*portable/ThirdParty/GCC/Posix/port*',
4040
r'.*portable.*Xtensa_ESP32\/include\/portmacro\.h',
41+
r'.*portable.*CDK\/T-HEAD_CK802\/portmacro\.h',
42+
r'.*portable.*GCC\/Posix\/portmacro\.h',
4143
r'.*portable.*Xtensa_ESP32.*port\.c',
4244
r'.*portable.*Xtensa_ESP32.*portasm\.S',
4345
r'.*portable.*Xtensa_ESP32.*xtensa_.*',

portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
#ifndef PORTMACRO_H
@@ -212,7 +211,7 @@
212211
#define portYIELD() vPortYield()
213212
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
214213
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
215-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
214+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 )
216215
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
217216
/*-----------------------------------------------------------*/
218217

portable/CCS/ARM_CM3/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827

@@ -92,7 +91,7 @@
9291

9392
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
9493
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
95-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) portYIELD()
94+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired != pdFALSE ) portYIELD(); } while( 0 )
9695
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
9796

9897
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)