Skip to content

Commit ccbbf04

Browse files
chinglee-iotUbuntu
andauthored
Update coverity example README (#1020)
* Update coverity example README * Update main.c for comment --------- Co-authored-by: Ubuntu <[email protected]>
1 parent 52ee9fa commit ccbbf04

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

examples/cmake_example/main.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@
4343
/* Standard includes. */
4444
#include <stdio.h>
4545

46-
void exampleTask( void * parameters )
46+
/*-----------------------------------------------------------*/
47+
48+
static void exampleTask( void * parameters );
49+
50+
/*-----------------------------------------------------------*/
51+
52+
static void exampleTask( void * parameters )
4753
{
4854
/* Unused parameters. */
4955
( void ) parameters;
@@ -61,15 +67,15 @@ void main( void )
6167
static StaticTask_t exampleTaskTCB;
6268
static StackType_t exampleTaskStack[ configMINIMAL_STACK_SIZE ];
6369

64-
printf( "Example FreeRTOS Project\n" );
70+
( void ) printf( "Example FreeRTOS Project\n" );
6571

66-
xTaskCreateStatic( exampleTask,
67-
"example",
68-
configMINIMAL_STACK_SIZE,
69-
NULL,
70-
configMAX_PRIORITIES - 1,
71-
&( exampleTaskStack[ 0 ] ),
72-
&( exampleTaskTCB ) );
72+
( void ) xTaskCreateStatic( exampleTask,
73+
"example",
74+
configMINIMAL_STACK_SIZE,
75+
NULL,
76+
configMAX_PRIORITIES - 1U,
77+
&( exampleTaskStack[ 0 ] ),
78+
&( exampleTaskTCB ) );
7379

7480
/* Start the scheduler. */
7581
vTaskStartScheduler();
@@ -81,12 +87,16 @@ void main( void )
8187
}
8288
/*-----------------------------------------------------------*/
8389

84-
void vApplicationStackOverflowHook( TaskHandle_t xTask,
85-
char * pcTaskName )
86-
{
87-
/* Check pcTaskName for the name of the offending task,
88-
* or pxCurrentTCB if pcTaskName has itself been corrupted. */
89-
( void ) xTask;
90-
( void ) pcTaskName;
91-
}
90+
#if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
91+
92+
void vApplicationStackOverflowHook( TaskHandle_t xTask,
93+
char * pcTaskName )
94+
{
95+
/* Check pcTaskName for the name of the offending task,
96+
* or pxCurrentTCB if pcTaskName has itself been corrupted. */
97+
( void ) xTask;
98+
( void ) pcTaskName;
99+
}
100+
101+
#endif /* #if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) */
92102
/*-----------------------------------------------------------*/

examples/coverity/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run [Synopsys Coverity](https://www.synopsys.com/software-integrity/security-tes
44
for checking MISRA compliance.
55

66
> **Note**
7-
Coverity version 2022.6.1 incorrectly infers the type of `pdTRUE` and `pdFALSE`
7+
Coverity version 2023.6.1 incorrectly infers the type of `pdTRUE` and `pdFALSE`
88
as boolean because of their names, resulting in multiple false positive warnings
99
about type mismatch. We replace `pdTRUE` with `pdPASS` and `pdFALSE` with
1010
`pdFAIL` to avoid these false positive warnings. This workaround will not be
@@ -40,15 +40,14 @@ commands in a terminal:
4040
3. Build the (pseudo) application:
4141
~~~
4242
cd build/
43-
cov-build --emit-complementary-info --dir cov-out make
43+
cov-build --emit-complementary-info --dir cov-out make coverity
4444
~~~
4545
4. Go to the Coverity output directory (`cov-out`) and begin Coverity static
4646
analysis:
4747
~~~
48-
cd cov-out/
4948
cov-analyze --dir ./cov-out \
5049
--coding-standard-config ../examples/coverity/coverity_misra.config \
51-
--tu-pattern "file('.*/FreeRTOS/Source/[A-Za-z_]*\.c')
50+
--tu-pattern "file('[A-Za-z_]+\.c')"
5251
~~~
5352
5. Generate the HTML report:
5453
~~~

0 commit comments

Comments
 (0)