Skip to content

Commit 0b9a497

Browse files
thirtytwobitsjasonpcarrolltony-josi-aws
authored
Enabling user control of compiler analysis for non ISO statements (FreeRTOS#1140)
* Enabling user control of compiler analysis for non ISO statements Description ----------- This change replaces the GCC-specific fix for -pedantic in FreeRTOS_Sockets.c with a configurable solution. The change has no functional impact. Test Steps ----------- Compiles with GCC, -pedantic, and -Werror Checklist: ---------- - [ ] I have tested my changes. No regression in existing tests. - [ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request. - [x] I have tested by changes but have not run the existing tests. Related Issue ----------- (none) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. # Conflicts: # source/FreeRTOS_Sockets.c * Update source/include/FreeRTOSIPConfigDefaults.h Co-authored-by: jasonpcarroll <[email protected]> * Fixing bad merge and formatting --------- Co-authored-by: jasonpcarroll <[email protected]> Co-authored-by: Tony Josi <[email protected]>
1 parent f402693 commit 0b9a497

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

source/FreeRTOS_Sockets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,9 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket,
29012901
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-111 */
29022902
/* coverity[misra_c_2012_rule_11_8_violation] */
29032903
/* coverity[misra_c_2012_rule_11_1_violation] */
2904+
ipconfigISO_STRICTNESS_VIOLATION_START;
29042905
pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue;
2906+
ipconfigISO_STRICTNESS_VIOLATION_END;
29052907
xReturn = 0;
29062908
break;
29072909
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */

source/include/FreeRTOSIPConfigDefaults.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3374,6 +3374,43 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY );
33743374

33753375
/*---------------------------------------------------------------------------*/
33763376

3377+
/*
3378+
* ipconfigISO_STRICTNESS_VIOLATION_START, ipconfigISO_STRICTNESS_VIOLATION_END
3379+
*
3380+
* Type: compiler pragma injection macros
3381+
*
3382+
* These two macros enclose parts of the source that contain intentional
3383+
* deviations from the ISO C standard. Users, and AI (I welcome our robot
3384+
* overlords!), can use this to customize static analysis settings such as
3385+
* the `-pedantic` flag in GCC. These should appear in very few places within
3386+
* the FreeRTOS TCP source and should enclose only a line or two at a time.
3387+
* When first introduced, these macros enclosed a single line of source code in
3388+
* the sockets implementation.
3389+
*
3390+
* GCC example
3391+
*
3392+
* In gcc, to allow the Free RTOS TCP code to compile with `-pedantic` you can
3393+
* define these macros as such:
3394+
*
3395+
* ```
3396+
* // Last tested in GCC 10
3397+
* #define ipconfigISO_STRICTNESS_VIOLATION_START _Pragma("GCC diagnostic push") \
3398+
* _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
3399+
*
3400+
* #define ipconfigISO_STRICTNESS_VIOLATION_END _Pragma("GCC diagnostic pop")
3401+
* ```
3402+
*/
3403+
3404+
#ifndef ipconfigISO_STRICTNESS_VIOLATION_START
3405+
#define ipconfigISO_STRICTNESS_VIOLATION_START
3406+
#endif
3407+
3408+
#ifndef ipconfigISO_STRICTNESS_VIOLATION_END
3409+
#define ipconfigISO_STRICTNESS_VIOLATION_END
3410+
#endif
3411+
3412+
/*---------------------------------------------------------------------------*/
3413+
33773414
/* Should only be included here, ensures trace config is set first. */
33783415
#include "IPTraceMacroDefaults.h"
33793416

0 commit comments

Comments
 (0)