Skip to content

Commit

Permalink
Enabling user control of compiler analysis for non ISO statements (#1140
Browse files Browse the repository at this point in the history
)

* 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 <23126711+jasonpcarroll@users.noreply.github.com>

* Fixing bad merge and formatting

---------

Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
Co-authored-by: Tony Josi <tonyjosi@amazon.com>
  • Loading branch information
3 people committed May 6, 2024
1 parent f402693 commit 0b9a497
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/FreeRTOS_Sockets.c
Expand Up @@ -2901,7 +2901,9 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket,
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-111 */
/* coverity[misra_c_2012_rule_11_8_violation] */
/* coverity[misra_c_2012_rule_11_1_violation] */
ipconfigISO_STRICTNESS_VIOLATION_START;
pxSocket->pxUserWakeCallback = ( SocketWakeupCallback_t ) pvOptionValue;
ipconfigISO_STRICTNESS_VIOLATION_END;
xReturn = 0;
break;
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */
Expand Down
37 changes: 37 additions & 0 deletions source/include/FreeRTOSIPConfigDefaults.h
Expand Up @@ -3374,6 +3374,43 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY );

/*---------------------------------------------------------------------------*/

/*
* ipconfigISO_STRICTNESS_VIOLATION_START, ipconfigISO_STRICTNESS_VIOLATION_END
*
* Type: compiler pragma injection macros
*
* These two macros enclose parts of the source that contain intentional
* deviations from the ISO C standard. Users, and AI (I welcome our robot
* overlords!), can use this to customize static analysis settings such as
* the `-pedantic` flag in GCC. These should appear in very few places within
* the FreeRTOS TCP source and should enclose only a line or two at a time.
* When first introduced, these macros enclosed a single line of source code in
* the sockets implementation.
*
* GCC example
*
* In gcc, to allow the Free RTOS TCP code to compile with `-pedantic` you can
* define these macros as such:
*
* ```
* // Last tested in GCC 10
* #define ipconfigISO_STRICTNESS_VIOLATION_START _Pragma("GCC diagnostic push") \
* _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
*
* #define ipconfigISO_STRICTNESS_VIOLATION_END _Pragma("GCC diagnostic pop")
* ```
*/

#ifndef ipconfigISO_STRICTNESS_VIOLATION_START
#define ipconfigISO_STRICTNESS_VIOLATION_START
#endif

#ifndef ipconfigISO_STRICTNESS_VIOLATION_END
#define ipconfigISO_STRICTNESS_VIOLATION_END
#endif

/*---------------------------------------------------------------------------*/

/* Should only be included here, ensures trace config is set first. */
#include "IPTraceMacroDefaults.h"

Expand Down

0 comments on commit 0b9a497

Please sign in to comment.