From 5c0449a63a1a0dbdd1c7250854957a0b5f36a70c Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Sat, 7 Oct 2023 13:58:07 +0800 Subject: [PATCH] change(freertos/idf): Update single-core macros to prevent unused variable error Various convenience macros in tasks.c will simply leave macro arguments unused when built for single-core. This leads to an 'unused variable' warning. This commit updates those macrso so that the unused arguments have a '(void)' statement. --- components/freertos/FreeRTOS-Kernel/tasks.c | 36 ++++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/components/freertos/FreeRTOS-Kernel/tasks.c b/components/freertos/FreeRTOS-Kernel/tasks.c index 2644f5c1e4..987821e178 100644 --- a/components/freertos/FreeRTOS-Kernel/tasks.c +++ b/components/freertos/FreeRTOS-Kernel/tasks.c @@ -201,8 +201,19 @@ #define taskIS_YIELD_REQUIRED( pxTCB, xCurCoreID, xYieldEqualPriority ) prvIsYieldUsingPrioritySMP( ( pxTCB )->uxPriority, ( pxTCB )->xCoreID, xCurCoreID, xYieldEqualPriority ) #define taskIS_YIELD_REQUIRED_USING_PRIORITY( uxTaskPriority, xTaskCoreID, xCurCoreID, xYieldEqualPriority ) prvIsYieldUsingPrioritySMP( uxTaskPriority, xTaskCoreID, xCurCoreID, xYieldEqualPriority ) #else - #define taskIS_YIELD_REQUIRED( pxTCB, xCurCoreID, xYieldEqualPriority ) ( ( ( ( pxTCB )->uxPriority + ( ( xYieldEqualPriority == pdTRUE ) ? 1 : 0 ) ) > pxCurrentTCBs[ 0 ]->uxPriority ) ? pdTRUE : pdFALSE ) - #define taskIS_YIELD_REQUIRED_USING_PRIORITY( uxTaskPriority, xTaskCoreID, xCurCoreID, xYieldEqualPriority ) ( ( ( uxTaskPriority + ( ( xYieldEqualPriority == pdTRUE ) ? 1 : 0 ) ) >= pxCurrentTCBs[ 0 ]->uxPriority ) ? pdTRUE : pdFALSE ) + #define taskIS_YIELD_REQUIRED( pxTCB, xCurCoreID, xYieldEqualPriority ) \ + ( { \ + /* xCurCoreID is unused */ \ + ( void ) xCurCoreID; \ + ( ( ( pxTCB )->uxPriority + ( ( xYieldEqualPriority == pdTRUE ) ? 1 : 0 ) ) > pxCurrentTCBs[ 0 ]->uxPriority ) ? pdTRUE : pdFALSE; \ + } ) + #define taskIS_YIELD_REQUIRED_USING_PRIORITY( uxTaskPriority, xTaskCoreID, xCurCoreID, xYieldEqualPriority ) \ + ( { \ + /* xTaskCoreID and xCurCoreID are unused */ \ + ( void ) xTaskCoreID; \ + ( void ) xCurCoreID; \ + ( ( uxTaskPriority + ( ( xYieldEqualPriority == pdTRUE ) ? 1 : 0 ) ) >= pxCurrentTCBs[ 0 ]->uxPriority ) ? pdTRUE : pdFALSE; \ + } ) #endif /* configNUMBER_OF_CORES > 1 */ /*-----------------------------------------------------------*/ @@ -215,7 +226,12 @@ #if ( configNUMBER_OF_CORES > 1 ) #define taskIS_AFFINITY_COMPATIBLE( xCore, xCoreID ) ( ( ( ( xCoreID ) == xCore ) || ( ( xCoreID ) == tskNO_AFFINITY ) ) ? pdTRUE : pdFALSE ) #else - #define taskIS_AFFINITY_COMPATIBLE( xCore, xCoreID ) ( pdTRUE ) + #define taskIS_AFFINITY_COMPATIBLE( xCore, xCoreID ) \ + ( { \ + /* xCoreID is unused */ \ + ( void ) xCoreID; \ + pdTRUE; \ + } ) #endif /* configNUMBER_OF_CORES > 1 */ /*-----------------------------------------------------------*/ @@ -225,7 +241,12 @@ #define taskIS_CURRENTLY_RUNNING_ON_CORE( pxTCB, xCoreID ) ( ( ( pxTCB ) == pxCurrentTCBs[ ( xCoreID ) ] ) ? pdTRUE : pdFALSE ) #else #define taskIS_CURRENTLY_RUNNING( pxTCB ) ( ( ( pxTCB ) == pxCurrentTCBs[ 0 ] ) ? pdTRUE : pdFALSE ) - #define taskIS_CURRENTLY_RUNNING_ON_CORE( pxTCB, xCoreID ) taskIS_CURRENTLY_RUNNING( pxTCB ) + #define taskIS_CURRENTLY_RUNNING_ON_CORE( pxTCB, xCoreID ) \ + ( { \ + /* xCoreID is unused */ \ + ( void ) xCoreID; \ + taskIS_CURRENTLY_RUNNING( pxTCB ); \ + } ) #endif /* configNUMBER_OF_CORES > 1 */ /*-----------------------------------------------------------*/ @@ -234,7 +255,12 @@ #if ( configNUMBER_OF_CORES > 1 ) #define taskCAN_BE_SCHEDULED( pxTCB ) prvCheckTaskCanBeScheduledSMP( pxTCB ) #else - #define taskCAN_BE_SCHEDULED( pxTCB ) ( ( ( uxSchedulerSuspended[ 0 ] == ( UBaseType_t ) 0U ) ) ? pdTRUE : pdFALSE ) + #define taskCAN_BE_SCHEDULED( pxTCB ) \ + ( { \ + /* pxTCB is unused */ \ + ( void ) pxTCB; \ + ( ( uxSchedulerSuspended[ 0 ] == ( UBaseType_t ) 0U ) ) ? pdTRUE : pdFALSE; \ + } ) #endif /* configNUMBER_OF_CORES > 1 */ /*-----------------------------------------------------------*/