Misra 20.7 compatibility

Rule 20.7 Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses

such like

// ./FreeRTOS/Source/croutine.c line 68
    #define prvAddCoRoutineToReadyQueue( pxCRCB )                       \
    {                                                                   \
        if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority )          \
        {                                                               \
            uxTopCoRoutineReadyPriority = pxCRCB->uxPriority;           \
        }                                                               \
        vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \
    }

What are you trying to use croutine.c for? Does the following addresses this violation -

#define prvAddCoRoutineToReadyQueue( pxCRCB ) \
{ \
    if( ( pxCRCB )->uxPriority > uxTopCoRoutineReadyPriority ) \
    { \
        uxTopCoRoutineReadyPriority = ( pxCRCB )->uxPriority; \
    } \
    vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ ( pxCRCB )->uxPriority ] ), &( ( pxCRCB )->xGenericListItem ) ); \
}

Co-routines have been deprecated for some time.

1 Like

Yes, this is an another violation

I was asking if the code I pasted addresses the violation you mentioned. As Richard mentioned, co-routines have been deprecated. Are you using co-routines?

Oh, I am sorry, the code you pasted can address this violation.
I’m not using co-routines.
My company is developing a static analysis tool about Misra rules, and we just run our tool on some open source projects, like FreeRTOS.
So we don’t know that co-routines have been deprecated.
Thanks for your reply!

However, in addition to coroutines, some files have this problem, such as below in FreeRTOS/Source/include/FreeRTOS.h


#ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
    #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue )    ( void ) uxSavedStatusValue
#endif

#ifndef portCLEAN_UP_TCB
    #define portCLEAN_UP_TCB( pxTCB )    ( void ) pxTCB
#endif

These are fixed with this PR - Add support for MISRA rule 20.7 by moninom1 · Pull Request #546 · FreeRTOS/FreeRTOS-Kernel · GitHub

Thank you for bringing this to attention.