From 18d238ad5cc21ec53008cd21c62c2c10414db3c2 Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon, 31 Aug 2020 12:55:38 -0700 Subject: [PATCH] Address a few MISRA 2.2 violations in FreeRTOS_IP.c (#230) * Make changes for MISRA rule 2.2 * Add comments to explain changes * Fix a typo * Actually fix a typo I missed a spot in the previous commit. --- FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c index 5dff8ef4a..007880473 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c @@ -2105,6 +2105,11 @@ uint8_t ucProtocol; if( xResult != pdPASS ) { FreeRTOS_printf( ( "xCheckSizeFields: location %ld\n", xLocation ) ); + + /* If FreeRTOS_printf is not defined, not using xLocation will be a violation of MISRA + * rule 2.2 as the value assigned to xLocation will not be used. The below statement uses + * the variable without modifying the logic of the source. */ + ( void ) xLocation; } return xResult; @@ -2379,6 +2384,11 @@ BaseType_t location = 0; ( usChecksum == ipINVALID_LENGTH ) ) { FreeRTOS_printf( ( "CRC error: %04x location %ld\n", usChecksum, location ) ); + + /* If FreeRTOS_printf is not defined, not using 'location' will be a violation of MISRA + * rule 2.2 as the value assigned to 'location' will not be used. The below statement uses + * the variable without modifying the logic of the source. */ + ( void ) location; } return usChecksum;