From 26a0bfcbc20d195fa60dd8cebcf5c7fc68d7bdeb Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 18 Jun 2024 11:56:09 +0200 Subject: [PATCH] score: Improve _ISR_lock_Initialize() Use do {} while (0) approach to avoid stray ';'. Update #4957 and #5038. --- cpukit/include/rtems/score/isrlock.h | 3 ++- testsuites/validation/tc-intr-non-smp.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cpukit/include/rtems/score/isrlock.h b/cpukit/include/rtems/score/isrlock.h index a965a9c070..d411e30c6d 100644 --- a/cpukit/include/rtems/score/isrlock.h +++ b/cpukit/include/rtems/score/isrlock.h @@ -200,7 +200,8 @@ static inline void _ISR_lock_Context_set_level( #define _ISR_lock_Initialize( _lock, _name ) \ _SMP_lock_Initialize( &( _lock )->Lock, _name ) #else - #define _ISR_lock_Initialize( _lock, _name ) (void) _name; + #define _ISR_lock_Initialize( _lock, _name ) \ + do { (void) _name; } while (0) #endif /** diff --git a/testsuites/validation/tc-intr-non-smp.c b/testsuites/validation/tc-intr-non-smp.c index 4476d98562..909301bc62 100644 --- a/testsuites/validation/tc-intr-non-smp.c +++ b/testsuites/validation/tc-intr-non-smp.c @@ -82,8 +82,8 @@ * - Check that RTEMS_INTERRUPT_LOCK_INITIALIZER() expands to an empty * structure initializer. * - * - Check that rtems_interrupt_lock_initialize() expands to white space - * only. + * - Check that rtems_interrupt_lock_initialize() expands to a code block + * which marks the second parameter as used. * * - Check that rtems_interrupt_lock_acquire_isr() expands to a code block * which marks the second parameter as used. @@ -139,10 +139,11 @@ static void RtemsIntrValIntrNonSmp_Action_0( void ) T_true( IsEqualIgnoreWhiteSpace( s, "{}" ) ); /* - * Check that rtems_interrupt_lock_initialize() expands to white space only. + * Check that rtems_interrupt_lock_initialize() expands to a code block which + * marks the second parameter as used. */ s = RTEMS_XSTRING( rtems_interrupt_lock_initialize( x, y ) ); - T_true( IsEqualIgnoreWhiteSpace( s, "(void)y;" ) ); + T_true( IsEqualIgnoreWhiteSpace( s, "do{(void)y;}while(0)" ) ); /* * Check that rtems_interrupt_lock_acquire_isr() expands to a code block