Skip to content

Commit d0a490e

Browse files
authored
Remove empty expression statement compiler warning (#692)
* Add do while( 0 ) loop for empty expression statement compiler warning
1 parent 1c5eca3 commit d0a490e

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

croutine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
* used from within an ISR.
6767
*/
6868
#define prvAddCoRoutineToReadyQueue( pxCRCB ) \
69-
{ \
69+
do { \
7070
if( ( pxCRCB )->uxPriority > uxTopCoRoutineReadyPriority ) \
7171
{ \
7272
uxTopCoRoutineReadyPriority = ( pxCRCB )->uxPriority; \
7373
} \
7474
vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ ( pxCRCB )->uxPriority ] ), &( ( pxCRCB )->xGenericListItem ) ); \
75-
}
75+
} while( 0 )
7676

7777
/*
7878
* Utility to ready all the lists used by the scheduler. This is called

include/croutine.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,14 @@ void vCoRoutineSchedule( void );
307307
* \defgroup crDELAY crDELAY
308308
* \ingroup Tasks
309309
*/
310-
#define crDELAY( xHandle, xTicksToDelay ) \
311-
if( ( xTicksToDelay ) > 0 ) \
312-
{ \
313-
vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \
314-
} \
315-
crSET_STATE0( ( xHandle ) );
310+
#define crDELAY( xHandle, xTicksToDelay ) \
311+
do { \
312+
if( ( xTicksToDelay ) > 0 ) \
313+
{ \
314+
vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \
315+
} \
316+
crSET_STATE0( ( xHandle ) ); \
317+
} while( 0 )
316318

317319
/**
318320
* @code{c}
@@ -400,7 +402,7 @@ void vCoRoutineSchedule( void );
400402
* \ingroup Tasks
401403
*/
402404
#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \
403-
{ \
405+
do { \
404406
*( pxResult ) = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), ( xTicksToWait ) ); \
405407
if( *( pxResult ) == errQUEUE_BLOCKED ) \
406408
{ \
@@ -412,7 +414,7 @@ void vCoRoutineSchedule( void );
412414
crSET_STATE1( ( xHandle ) ); \
413415
*pxResult = pdPASS; \
414416
} \
415-
}
417+
} while( 0 )
416418

417419
/**
418420
* croutine. h
@@ -494,7 +496,7 @@ void vCoRoutineSchedule( void );
494496
* \ingroup Tasks
495497
*/
496498
#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \
497-
{ \
499+
do { \
498500
*( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), ( xTicksToWait ) ); \
499501
if( *( pxResult ) == errQUEUE_BLOCKED ) \
500502
{ \
@@ -506,7 +508,7 @@ void vCoRoutineSchedule( void );
506508
crSET_STATE1( ( xHandle ) ); \
507509
*( pxResult ) = pdPASS; \
508510
} \
509-
}
511+
} while( 0 )
510512

511513
/**
512514
* croutine. h

include/semphr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ typedef QueueHandle_t SemaphoreHandle_t;
9595
*/
9696
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
9797
#define vSemaphoreCreateBinary( xSemaphore ) \
98-
{ \
98+
do { \
9999
( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \
100100
if( ( xSemaphore ) != NULL ) \
101101
{ \
102102
( void ) xSemaphoreGive( ( xSemaphore ) ); \
103103
} \
104-
}
104+
} while( 0 )
105105
#endif
106106

107107
/**

include/stack_macros.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757

5858
/* Only the current stack state is to be checked. */
5959
#define taskCHECK_FOR_STACK_OVERFLOW() \
60-
{ \
60+
do { \
6161
/* Is the currently saved stack pointer within the stack limit? */ \
6262
if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \
6363
{ \
6464
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
6565
} \
66-
}
66+
} while( 0 )
6767

6868
#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
6969
/*-----------------------------------------------------------*/
@@ -72,14 +72,14 @@
7272

7373
/* Only the current stack state is to be checked. */
7474
#define taskCHECK_FOR_STACK_OVERFLOW() \
75-
{ \
75+
do { \
7676
\
7777
/* Is the currently saved stack pointer within the stack limit? */ \
7878
if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \
7979
{ \
8080
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
8181
} \
82-
}
82+
} while( 0 )
8383

8484
#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
8585
/*-----------------------------------------------------------*/
@@ -106,7 +106,7 @@
106106
#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
107107

108108
#define taskCHECK_FOR_STACK_OVERFLOW() \
109-
{ \
109+
do { \
110110
int8_t * pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
111111
static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
112112
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
@@ -122,7 +122,7 @@
122122
{ \
123123
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
124124
} \
125-
}
125+
} while( 0 )
126126

127127
#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
128128
/*-----------------------------------------------------------*/

stream_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
*/
7979
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
8080
#define prvRECEIVE_COMPLETED( pxStreamBuffer ) \
81-
{ \
81+
do { \
8282
if( ( pxStreamBuffer )->pxReceiveCompletedCallback != NULL ) \
8383
{ \
8484
( pxStreamBuffer )->pxReceiveCompletedCallback( ( pxStreamBuffer ), pdFALSE, NULL ); \
@@ -87,7 +87,7 @@
8787
{ \
8888
sbRECEIVE_COMPLETED( ( pxStreamBuffer ) ); \
8989
} \
90-
}
90+
} while( 0 )
9191
#else /* if ( configUSE_SB_COMPLETED_CALLBACK == 1 ) */
9292
#define prvRECEIVE_COMPLETED( pxStreamBuffer ) sbRECEIVE_COMPLETED( ( pxStreamBuffer ) )
9393
#endif /* if ( configUSE_SB_COMPLETED_CALLBACK == 1 ) */
@@ -116,7 +116,7 @@
116116
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
117117
#define prvRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, \
118118
pxHigherPriorityTaskWoken ) \
119-
{ \
119+
do { \
120120
if( ( pxStreamBuffer )->pxReceiveCompletedCallback != NULL ) \
121121
{ \
122122
( pxStreamBuffer )->pxReceiveCompletedCallback( ( pxStreamBuffer ), pdTRUE, ( pxHigherPriorityTaskWoken ) ); \
@@ -125,7 +125,7 @@
125125
{ \
126126
sbRECEIVE_COMPLETED_FROM_ISR( ( pxStreamBuffer ), ( pxHigherPriorityTaskWoken ) ); \
127127
} \
128-
}
128+
} while( 0 )
129129
#else /* if ( configUSE_SB_COMPLETED_CALLBACK == 1 ) */
130130
#define prvRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken ) \
131131
sbRECEIVE_COMPLETED_FROM_ISR( ( pxStreamBuffer ), ( pxHigherPriorityTaskWoken ) )

tasks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@
124124
/* uxTopReadyPriority holds the priority of the highest priority ready
125125
* state task. */
126126
#define taskRECORD_READY_PRIORITY( uxPriority ) \
127-
{ \
127+
do { \
128128
if( ( uxPriority ) > uxTopReadyPriority ) \
129129
{ \
130130
uxTopReadyPriority = ( uxPriority ); \
131131
} \
132-
} /* taskRECORD_READY_PRIORITY */
132+
} while( 0 ) /* taskRECORD_READY_PRIORITY */
133133

134134
/*-----------------------------------------------------------*/
135135

0 commit comments

Comments
 (0)