-
Notifications
You must be signed in to change notification settings - Fork 207
Misra fix or suppress remaining violations #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
35d787d
a76d481
18dfde3
e0c458c
68d597c
9541e0d
13c58cb
57caf76
a9dd58d
d2f5158
1567226
2d2e745
40c82c9
e3156cc
81e90d8
0ece037
6f6d630
fb24ef8
46705be
561419c
464ff7b
c945cde
5ab12ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,35 @@ _Ref 8.9.1_ | |
| order of execution, some variables have file scope definitions rather | ||
| than function scope. | ||
|
|
||
| #### Rule 8.13 | ||
| _Ref 8.13.1_ | ||
|
|
||
| - MISRA C-2012 Rule 8.13 Parameter passed is never used, should be declared as | ||
| const. The argument passed to the `prvIPTask` function is left unused which is | ||
| considered as the variable not being used and thus warranting the use of `const`. | ||
| However, the FreeRTOS-kernel function `xTaskCreate` expects a function signature | ||
| of type `void vSomeFunction( void * pvArgs )`. To satisfy that requirement, the | ||
| function signature of `prvIPTask` does not have a `const` qualifier in the | ||
| parameter signature. | ||
|
|
||
| #### Rule 10.5 | ||
| _Ref 10.5.1_ | ||
|
|
||
| - MISRA C-2012 Rule 10.5 Converting from an unsigned to an enum type. The | ||
| operation is safe to perform in that case, as we are using a generic API | ||
| to send and receive data, in that case the exact data sent it is received | ||
|
|
||
| #### Rule 11.1 | ||
| _Ref 11.1.1_ | ||
|
|
||
| - MISRA C-2012 Rule 11.1 Converting from a void pointer to a function pointer. | ||
| The `FreeRTOS_setsockopt` API allows users to configure sockets by setting | ||
| various options. In order to do so, the function must accept one parameter | ||
| which, based on the option value, can be casted to the corresponding socket | ||
| field. To that end, that parameter is of `void *` type to accommodate all values. | ||
| The caller of the API is responsible for providing correct function pointer to the | ||
| API. Thus, this violation can be safely suppressed. | ||
|
|
||
| #### Rule 11.3 | ||
| _Ref 11.3.1_ | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about for 64-bit targets that do not allow 32-bit aligned access?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We currently do not support any hardware with that feature/drawback the only 64 bit we currently support is RiscV and they do support unaligned access (if i am not mistaken)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @paulbartell wrote:
A 64-bit target that do not allow 32-bit aligned access? I am not sure what you mean here. @Alfred2 wrote:
As for FreeRTOS+TCP, we also support the 64-bit UltraScale platform with a Cortex-A53. I have never seen alignment problems with the casting of types.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Cortex-A53 is only strict about alignment when configured such in the SCTLR. It's pretty common to configure it to allow unaligned access. In contrast, a Cortex-M0 (ARMv6-M) will always fail unaligned accesses.. but is 4-byte aligned. SPARC and MIPS are both example of a 64bit architectures that do not support unaligned access... So de-referencing a 32-bit aligned pointer as a 64bit type could cause a fault at runtime. In the case of FR+TCP, we're unlikely to run into this problem in particular. |
||
|
|
@@ -107,16 +136,6 @@ _Ref 14.3.1_ | |
| - MISRA C-2012 Rule 14.3 False positive as the value might be changed | ||
| depending on the conditionally compiled code | ||
|
|
||
| #### Rule 21.6 | ||
| _Ref 21.6.1_ | ||
|
|
||
| - MISRA C-2012 Rule 21.6 warns about the use of standard library input/output | ||
| functions as they might have implementation defined or undefined | ||
| behaviour. The function `snprintf` is used to insert information in a | ||
| logging string. This is only used in a utility function which aids in | ||
| debugging and is not part of the 'core' code governing the | ||
| functionality of the TCP/IP stack. | ||
|
|
||
| #### Rule 17.2 | ||
| _Ref 17.2.1_ | ||
|
|
||
|
|
@@ -128,10 +147,32 @@ _Ref 17.2.1_ | |
| have a secondary child socket thereby limiting the number of recursive | ||
| calls to one. | ||
|
|
||
| #### Rule 20.5 | ||
| _Ref 20.5.1_ | ||
|
|
||
| - MISRA C-2012 Rule 20.5 warns against the use of #undef. | ||
| FreeRTOS-Plus-TCP allows its users to set some configuration macros | ||
| to modify the behavior/performance of the library according to their | ||
| needs. However, the macros values must be within certain bounds. | ||
| To achieve that, if the macro values lie outside of the bounds, they | ||
| are undefined using `#undef` before being redefined to a proper | ||
| value. | ||
|
|
||
| #### Rule 20.10 | ||
| _Ref 20.10.1_ | ||
|
|
||
| - MISRA C-2012 Rule 20.10 warns against the use of ## concatination operator. | ||
| However, in this case, it must be used to support compile time | ||
| assertions in case the preprocessor does not suppport sizeof. This | ||
| operation (assert) has no runtime execution. | ||
|
|
||
| #### Rule 21.6 | ||
| _Ref 21.6.1_ | ||
|
|
||
| - MISRA C-2012 Rule 21.6 warns about the use of standard library input/output | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This justification should mention how we prevent misuse of printf-style functions. Mentioning "-Wformat-security" and/or specific Wformat options that are used when building unit tests would be helpful here. |
||
| functions as they might have implementation defined or undefined | ||
| behaviour. The function `snprintf` is used to insert information in a | ||
| logging string. This is only used in a utility function which aids in | ||
| debugging and is not part of the 'core' code governing the | ||
| functionality of the TCP/IP stack. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be re-worded to be more generic. Something like:
MISRA C-2012 Rule 8.13 encourages the use of const-qualified types whenever possible. However, the FreeRTOS API requires that all task entry functions conform to the same function signature (TaskFunction_t) which includes a single void * pointer argument. Due to this restriction, it is not possible to use a const qualifier for the entry point function to any FreeRTOS task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was fixed with this commit: 81e90d8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO: It's too specific to the particular instance. We're likely to run into this exact violation quite frequently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is ok to be specific might be even desirable, we do support multiple References for specific cases