Skip to content
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

Update coverity violation for SMP #81

Merged
Show file tree
Hide file tree
Changes from 116 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
c011734
Fix compile warnings and MISRA 2012 C Rule 1.1.
ActoryOu Nov 29, 2022
abc85d3
Fix MISRA C 2012 Directive 4.6.
ActoryOu Nov 29, 2022
3b05aba
Fix MISRA C 2012 Rule 1.1.
ActoryOu Nov 29, 2022
cb17335
Fix MISRA C 2012 Rule 17.3.
ActoryOu Nov 29, 2022
516fc6f
Fix MISRA C 2012 Rule 8.3.
ActoryOu Nov 29, 2022
3466371
Fix MISRA C 2012 Rule 8.4.
ActoryOu Nov 29, 2022
80785f9
Fix CHECKED_RETURN.
ActoryOu Nov 30, 2022
65fa1bb
Fix MISRA C 2012 Rule 10.1.
ActoryOu Nov 30, 2022
a9cbaa1
Fix MISRA C 2012 Rule 10.2.
ActoryOu Nov 30, 2022
1e14c65
Fix MISRA C 2012 Rule 10.3.
ActoryOu Nov 30, 2022
7857976
Fix MISRA C 2012 Rule 10.4.
ActoryOu Nov 30, 2022
e9d6e22
Fix MISRA C 2012 Rule 10.7.
ActoryOu Nov 30, 2022
d656d1d
Fix MISRA C 2012 Rule 10.8.
ActoryOu Nov 30, 2022
32295e7
Fix MISRA C 2012 Rule 11.3.
ActoryOu Nov 30, 2022
ee9a882
Fix MISRA C 2012 Rule 11.5.
ActoryOu Nov 30, 2022
e1a1db9
Fix MISRA C 2012 Rule 12.1.
ActoryOu Nov 30, 2022
7036d9d
Fix MISRA C 2012 Rule 13.3.
ActoryOu Nov 30, 2022
bc39734
Fix MISRA C 2012 Rule 14.3.
ActoryOu Nov 30, 2022
213e8f9
Fix MISRA C 2012 Rule 17.7.
ActoryOu Nov 30, 2022
b55b074
Fix MISRA C 2012 Rule 18.1.
ActoryOu Nov 30, 2022
178f9b9
Fix MISRA C 2012 Rule 8.13.
ActoryOu Nov 30, 2022
66665d2
Fix MISRA C 2012 Rule 8.5.
ActoryOu Nov 30, 2022
611cff6
Fix MISRA C 2012 Rule 8.6.
ActoryOu Nov 30, 2022
70903a3
Fix MISRA C 2012 Rule 8.9.
ActoryOu Nov 30, 2022
257c3e0
Fix MISRA C 2012 Rule 8.4.
ActoryOu Nov 30, 2022
f1ece17
Fix MISRA C 2012 Rule 8.5.
ActoryOu Nov 30, 2022
b73bf11
Fix MISRA C 2012 Rule 8.6.
ActoryOu Nov 30, 2022
59cf3f6
Revert unnecessary suppression.
ActoryOu Nov 30, 2022
5c6d77b
Add more description in MISRA.md
ActoryOu Nov 30, 2022
b278341
Fix formatting.
ActoryOu Nov 30, 2022
ef65fda
Fix MISRA.md
ActoryOu Nov 30, 2022
b998572
Fix comments.
ActoryOu Dec 5, 2022
646698d
Update MISRA.md for rule 8.9.
ActoryOu Dec 5, 2022
d29d3e2
Update MISRA.md for rule 8.5/8.6.
ActoryOu Dec 5, 2022
a244764
Wrap xYieldCount with configRUN_MULTIPLE_PRIORITIES. Fix comments.
ActoryOu Dec 5, 2022
99d3d54
Fix array-bounds compiler warning on gcc11+ in list.h (#580)
archigup Dec 15, 2022
6d65558
move the prototype for vApplicationIdleHook to task.h. (#600)
tcpluess Dec 19, 2022
aab4812
Update MISRA.md.
ActoryOu Dec 26, 2022
953f32e
Remove Dir 4.6 in MISRA.md.
ActoryOu Dec 28, 2022
bb6071e
Update equal priority task preemption (#603)
chinglee-iot Jan 6, 2023
8592fd2
Update FreeRTOS/FreeRTOS build checks (#613)
aggarg Jan 16, 2023
78319fd
Add ulTaskGetRunTimeCounter and ulTaskGetRunTimePercent (#611)
chrisnc Jan 19, 2023
260a37c
Fix some CMake documentation typos (#616)
davefiddes Jan 23, 2023
88674cb
Update the uxSchedulerSuspended after prvCheckForRunStateChange
chinglee-iot Jan 30, 2023
91c20f5
Added support of 64bit events. (#597)
Hadatko Feb 3, 2023
050cf0d
Introduce portMEMORY_BARRIER for Microblaze port. (#621)
bbain Feb 13, 2023
8252ede
Do not call exit() on MSVC Port when calling vPortEndScheduler (#624)
Ju1He1 Feb 15, 2023
ba1deb5
Update PR template to include checkbox for Unit Test related changes…
AniruddhaKanhere Feb 20, 2023
5d05601
Fix build failure introduced in PR #597 (#629)
aggarg Feb 23, 2023
8cd5451
Feature/fixing clang gnu compiler warnings (#620)
phelter Feb 23, 2023
cd87681
POSIX port fixes (#626)
jacky309 Feb 27, 2023
5fdbb7f
Cortex-M35P: Add Cortex-M35P port (#631)
urutva Feb 28, 2023
0a70ecb
Introduced Github Status Badge for Unit Tests (#634)
amazonKamath Feb 28, 2023
e6514fb
Remove C99 requirement from CMake file (#633)
aggarg Mar 2, 2023
c3e1df0
Add Thread Local Storage (TLS) support using Picolibc functions (#343)
keith-packard Mar 2, 2023
a9e1f66
Interrupt priority assert improvements for CM3/4/7 (#602)
chrisnc Mar 2, 2023
97acc2e
Introduced code coverage status badge (#635)
amazonKamath Mar 2, 2023
ddd50d9
added portPOINTER_SIZE_TYPE and SIZE_MAX definition to PIC24/dsPIC po…
n9wxu Mar 4, 2023
563c57e
Fix TLS and stack alignment when using picolibc (#637)
keith-packard Mar 6, 2023
7b26ea6
Enable building the GCC Cortex-R5 port without an FPU (#586)
paulbartell Mar 6, 2023
309a18a
Fix freertos_kernel cmake property, Posix Port (#640)
kstribrnAmzn Mar 7, 2023
55658e1
Add missing FreeRTOS+ defines
Mar 11, 2023
d4d5e43
Run kernel demos and unit tests for PR changes (#645)
aggarg Mar 17, 2023
4600c94
Merge branch 'smp-dev-complete-merge-candidate-history' into misra-SM…
chinglee-iot Mar 21, 2023
9488ba2
Add functions to get the buffers of statically created objects (#641)
Dazza0 Mar 22, 2023
99797e1
Cortex-M Assert when NVIC implements 8 PRIO bits (#639)
kar-rahul-aws Mar 23, 2023
97e58da
Remove C90 requirement from CMakeLists (#649)
aggarg Mar 28, 2023
68f1053
Only add alignment padding when needed (#650)
aggarg Mar 28, 2023
1b8a424
add a missing comma (#651)
nbrunner Mar 29, 2023
aa987a3
fix conversion warning (#658)
votrungchi Apr 4, 2023
6cbb783
Merge branch 'smp-dev-complete-merge-candidate-history' into update-i…
chinglee-iot Apr 20, 2023
029ce2a
Merge branch 'smp-dev-complete-merge-candidate-history' into misra-SM…
chinglee-iot Apr 20, 2023
435c44a
Merge pull request #1 from chinglee-iot/misra-SMP-rebase20221130
ActoryOu Apr 20, 2023
686b6e6
ARMv7M: Adjust implemented priority bit assertions (#665)
paulbartell Apr 20, 2023
d8d2454
Update get idle tasks stats
chinglee-iot Apr 20, 2023
3101a1a
Define portBASE_TYPE in XMOS AICORE porting
chinglee-iot Apr 20, 2023
5c094b5
Update enter critical from ISR API
chinglee-iot Apr 20, 2023
714e543
Format portmacro.h in arm CM0 ports
paulbartell Apr 18, 2023
5f19e34
portable/ARM_CM0: Add xPortIsInsideInterrupt
paulbartell Apr 18, 2023
452b893
Merge branch 'smp-dev-update-xmos-aicore-conflict' into smp-dev-candi…
chinglee-iot Apr 21, 2023
bef099f
Merge branch 'update-increase-uxSchedulerSuspended-after' into smp-de…
chinglee-iot Apr 21, 2023
c4be682
Merge branch 'smp-dev-complete-merge-candidate-history' into merge-ma…
chinglee-iot Apr 21, 2023
1871ef5
Merge branch 'merge-main-misra-SMP-rebase20221130' into smp-dev-candi…
chinglee-iot Apr 21, 2023
7b9edd4
Merge pull request #2 from chinglee-iot/merge-main-misra-SMP-rebase20…
ActoryOu Apr 21, 2023
a5f1094
Fix get task stats
chinglee-iot Apr 21, 2023
8bfec72
Merge branch 'smp-dev-fix-idle-task-stats' into smp-dev-candidate-202…
chinglee-iot Apr 21, 2023
39b3bea
Fix missing configNUM_CORES
chinglee-iot Apr 21, 2023
c35632e
Merge branch 'smp-dev-fix-idle-task-stats' into smp-dev-candidate-202…
chinglee-iot Apr 21, 2023
9d21b07
Merge branch 'main' into smp-dev-compelete-merge-main-20230424
chinglee-iot Apr 24, 2023
91ff650
Merge branch 'smp-dev-complete-merge-candidate-history' into smp-dev-…
chinglee-iot Apr 24, 2023
3cc732a
Merge branch 'smp-dev-complete-merge-candidate-history' into smp-dev-…
chinglee-iot Apr 24, 2023
5b0bda3
Merge branch 'smp-dev-compelete-merge-main-20230424' into smp-dev-can…
chinglee-iot Apr 24, 2023
f6ec3c7
Fix uncrustify
chinglee-iot Apr 24, 2023
8037d3b
Update lexicon
chinglee-iot Apr 24, 2023
4e2c58d
Remove tailing space
chinglee-iot Apr 24, 2023
c659463
Fix ulTotalRunTime and ulTaskSwitchedInTime
chinglee-iot Apr 24, 2023
8748c6e
Ignore XMOS AICORE header check
chinglee-iot Apr 24, 2023
c30474a
Merge branch 'smp-dev-complete-fix-demos' into smp-dev-candidate-2023…
chinglee-iot Apr 25, 2023
a4f5274
Merge branch 'smp-dev-complete-fix-uncrustify' into smp-dev-candidate…
chinglee-iot Apr 25, 2023
6d2b442
Fix MSVC build init array
chinglee-iot Apr 25, 2023
c3fefa6
Fix MSVC building.
ActoryOu Apr 25, 2023
42b59b5
Merge branch 'misra-SMP-rebase20221130' into smp-dev-candidate-20230424
chinglee-iot Apr 25, 2023
4af4493
Merge branch 'smp-dev-complete-merge-candidate-history' into smp-dev-…
chinglee-iot Apr 25, 2023
9b9a9c7
Merge branch 'smp-dev-complete-merge-candidate-history' into merge-ma…
chinglee-iot Apr 25, 2023
791e0c9
Fix for c90 compiler
chinglee-iot Apr 25, 2023
a108e90
Merge main to misra smp rebase20221130 (#3)
chinglee-iot Apr 25, 2023
bcb60fc
Merge branch 'misra-SMP-rebase20221130' into smp-dev-candidate-20230424
chinglee-iot Apr 25, 2023
0fb7154
Merge branch 'smp-dev-complete-merge-candidate-history' into misra-SM…
chinglee-iot Apr 25, 2023
4c7a8da
Fix MISRA violation in get idle run time counter
chinglee-iot Apr 25, 2023
239051f
Merge remote-tracking branch 'actory/misra-SMP-rebase20221130' into m…
chinglee-iot Apr 25, 2023
b9470a3
Fix CI check error
chinglee-iot Apr 25, 2023
7b03893
Merge branch 'merge-main-misra-SMP-rebase20221130' into smp-dev-candi…
chinglee-iot Apr 25, 2023
86f37cb
Merge branch 'merge-main-misra-SMP-rebase20221130' into smp-dev-candi…
chinglee-iot Apr 25, 2023
56a9c7e
Fix single MISRA violation
chinglee-iot Apr 25, 2023
ea595d9
Update for std C90
chinglee-iot Apr 26, 2023
a1eab5a
Fix uncrustify
chinglee-iot Apr 26, 2023
e590e34
Remove unnecessary MISRA suppression
chinglee-iot Apr 27, 2023
84b19fe
Remove unreferenced MISRA suppression in MISRA.md
chinglee-iot Apr 27, 2023
17e5526
Remove 11.3 supression
chinglee-iot Apr 27, 2023
58da3ff
Remove 11.3 in MISRA.md
chinglee-iot Apr 27, 2023
b3514bd
Add back the suppression for pxCurrentTCBs
chinglee-iot Apr 27, 2023
28fa919
Fix typo
chinglee-iot Apr 27, 2023
b8b6d95
Fix more coverity errors
chinglee-iot May 4, 2023
cf0d10f
Fix error
chinglee-iot May 4, 2023
16f7d73
Return pdTRUE or pdFALSE with macros
chinglee-iot May 4, 2023
d4d167a
Fix possible overrun in prvSelectHighestPriority task
chinglee-iot May 4, 2023
c515f6b
Remove const due to list operation
chinglee-iot May 4, 2023
f02ef03
Uncrustify tasks
chinglee-iot May 8, 2023
5c41147
Code review suggestions
aggarg May 15, 2023
dc01863
Code review suggestions - 2
aggarg May 15, 2023
4de5931
Update for misra rule 2.5
chinglee-iot May 15, 2023
7352171
Fix format
chinglee-iot May 15, 2023
12a0252
Add rule 8.7 and 11.5 in misra.config
chinglee-iot May 15, 2023
12d08d6
Fix uncrustify
chinglee-iot May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ coproc
coprocessor
coprocessors
coreid
coverity
covfs
cp
cpacr
Expand Down
113 changes: 113 additions & 0 deletions MISRA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# MISRA Compliance (for configNUMBER_OF_CORES > 1)

For now, FreeRTOS-Kernel only conforms [MISRA C:2012](https://www.misra.org.uk/misra-c) guidelines in SMP part (configNUMBER_OF_CORES > 1),
with the deviations listed below. Compliance is checked with Coverity static analysis. Refer to [configuration](#misra-configuration) to build an application for the tool to analyze.

### Suppressed with Coverity Comments
To find the violation references in the source files run grep on the source code
with ( Assuming rule 4.6 violation; with justification in point 1 ):
```
grep 'MISRA Ref 8.4.1' . -rI
```

#### Rule 8.4

_Ref 8.4.1_

- MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an object or function with external linkage is defined.
vTaskEnterCriticalFromISR()/vTaskExitCriticalFromISR are used at some ports.

#### Rule 8.5

_Ref 8.5.1_

- MISRA C:2012 Rule 8.5: An external object or function shall be declared once in one and only one file.
Function is declared in header file correctly. But the function name in task.h/tasks.c is different if portUSING_MPU_WRAPPERS enabled.

#### Rule 8.6

_Ref 8.6.1_

- MISRA C:2012 Rule 8.6: An identifier with external linkage shall have exactly one external definition.
Function is declared in header file correctly. But the function name in task.h/tasks.c is different if portUSING_MPU_WRAPPERS enabled.

#### Rule 8.9

_Ref 8.9.1_
chinglee-iot marked this conversation as resolved.
Show resolved Hide resolved

- MISRA C:2012 Rule 8.9: An object should be defined at block scope if its identifier only appears in a single function.
False alarm. This variable is actually used by several different functions.

#### Rule 11.3

_Ref 11.3.1_

- MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to object type and a pointer to a different object type.
Unusual cast is ok as the structures are designed to have the same alignment, this is checked by an assert.

_Ref 11.3.2_
chinglee-iot marked this conversation as resolved.
Show resolved Hide resolved

- MISRA C:2012 Rule 11.3: A cast shall not be performed between a pointer to object type and a pointer to a different object type.
The mini list structure is used as the list end to save RAM. This is checked and valid.

#### Rule 11.5

_Ref 11.5.1_
chinglee-iot marked this conversation as resolved.
Show resolved Hide resolved

- MISRA C:2012 Rule 11.5: A conversion should not be performed from pointer to void into pointer to object.
void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same.

#### Rule 18.1
chinglee-iot marked this conversation as resolved.
Show resolved Hide resolved

_Ref 18.1.1_

- MISRA C:2012 Rule 18.1: A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand.
Loop breaks before index overrun.

### MISRA configuration

Copy below content as misra.conf to run coverity on FreeRTOS-Kernel.

```
// MISRA C-2012 Rules
{
version : "2.0",
standard : "c2012",
title: "Coverity MISRA Configuration",
deviations : [
// Disable the following rules.
{
deviation: "Directive 4.8",
reason: "We include lots of header files from other sources such as the kernel which defines structures that violate that Dir"
},
{
deviation: "Directive 4.9",
reason: "It is important the FreeRTOS-Kernel is optimised to work on small micro-controllers. To achieve that, macros are being used."
},
{
deviation: "Rule 1.2",
reason: "Allow FreeRTOS-Kernel to use attributes."
},
{
deviation: "Rule 2.3",
reason: "The way we declare structures are conformant with the FreeRTOS libraries, which leaves somes types unused."
},
{
deviation: "Rule 2.4",
reason: "Structures are always declared with both a struct tag and typedef alias. Some of these structs are always referred to by their typedef alias and thus the corresponding tags are unused."
},
{
deviation: "Rule 2.5",
reason: "We use unused macros for backward compatibility in addition to macros comming from FreeRTOS"
},
{
deviation: "Rule 3.1",
reason: "We post links which contain // inside comments blocks"
},
{
deviation: "Rule 21.2",
reason: "Allow use of all names."
}
]
}
```
11 changes: 6 additions & 5 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
* \ingroup Tasks
*/
struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
typedef struct tskTaskControlBlock * TaskHandle_t;
typedef struct tskTaskControlBlock * TaskHandle_t;
typedef const struct tskTaskControlBlock * ConstTaskHandle_t;

/*
* Defines the prototype to which the application task hook function must
Expand Down Expand Up @@ -193,7 +194,7 @@ typedef enum
*
* \ingroup TaskUtils
*/
#define tskNO_AFFINITY ( ( UBaseType_t ) -1U )
#define tskNO_AFFINITY ( ( UBaseType_t ) -1 )

/**
* task. h
Expand Down Expand Up @@ -271,7 +272,7 @@ typedef enum
#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )

/* Checks if core ID is valid. */
#define taskVALID_CORE_ID( xCoreID ) ( ( BaseType_t ) ( ( 0 <= xCoreID ) && ( xCoreID < configNUMBER_OF_CORES ) ) )
#define taskVALID_CORE_ID( xCoreID ) ( ( ( ( BaseType_t ) 0 <= ( xCoreID ) ) && ( ( xCoreID ) < ( BaseType_t ) configNUMBER_OF_CORES ) ) )

/*-----------------------------------------------------------
* TASK CREATION API
Expand Down Expand Up @@ -746,7 +747,7 @@ typedef enum
* \defgroup vTaskAllocateMPURegions vTaskAllocateMPURegions
* \ingroup Tasks
*/
void vTaskAllocateMPURegions( TaskHandle_t xTask,
void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;

/**
Expand Down Expand Up @@ -1363,7 +1364,7 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
* }
* }
*/
UBaseType_t vTaskCoreAffinityGet( const TaskHandle_t xTask );
UBaseType_t vTaskCoreAffinityGet( ConstTaskHandle_t xTask );
#endif

#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
Expand Down
Loading