Skip to content

Commit 4c7d86a

Browse files
simheinnashif
authored andcommitted
sca: Add ECLAIR SCA configuration files.
Add the Eclair configuration files, which are needed to configure the static code analysis tool for the zephyr coding guidelines. Signed-off-by: Simon Hein <[email protected]>
1 parent 9bb46e6 commit 4c7d86a

16 files changed

+740
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-doc_begin="This header file is automatically generated by Autoconf."
2+
-file_tag+={adopted,"^zephyr/build/zephyr/include/generated/autoconf\\.h$"}
3+
-doc_end
4+
5+
-doc_begin="These files are automatically generated by gperf."
6+
-file_tag+={adopted,"^zephyr/build/zephyr/kobject_.*\\.c$"}
7+
-doc_end
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-setq=CPP_MANUAL,"https://gcc.gnu.org/onlinedocs/gcc-10.3.0/cpp.pdf"
2+
3+
-doc="Selection for reports that are fully contained in adopted code."
4+
-report_selector+={adopted_report,"all_area(!kind(culprit||evidence)||all_loc(all_exp(adopted||pseudo)))"}
5+
6+
-doc_begin="Adopted code is not meant to be read, reviewed or modified by human programmers:no developers' confusion is not possible. In addition, adopted code is assumed to work as is. Reports that are fully contained in adopted code are hidden/tagged with the 'adopted' tag."
7+
-config=MC3R1.R7.2,reports+={relied,adopted_report}
8+
-config=MC3R1.R10.3,reports+={relied,adopted_report}
9+
-config=MC3R1.R10.6,reports+={relied,adopted_report}
10+
-config=MC3R1.R12.1,reports+={relied,adopted_report}
11+
-doc_end
12+
13+
-doc_begin="Macro LOAPIC_BASE_ADDRESS, automatically generated by Autoconf, expands to an implicitly unsigned literal lacking the 'u' or 'U' suffix."
14+
-config=MC3R1.R7.2,reports+={safe,"all_area(all_loc(any_exp(macro(^assert$))))"}
15+
-doc_end
16+
17+
-doc="#include_next is a documented GNU preprocessing directive. See section \"2.7 Wrapper Headers\" of "CPP_MANUAL""
18+
-config=STD.prepdirc,directives+={safe,"^include_next$"}
19+
-doc="#warning is a documented GNU preprocessing directive. See section \"5 Diagnostics\" of "CPP_MANUAL""
20+
-config=STD.prepdirc,directives+={safe,"^warning$"}
21+
22+
-doc="The declarations in files tagged with api:public define a public API of Zephyr.
23+
Declarations in these files not necessarily have to be referenced."
24+
-config=MC3R1.R2.3,declarations+={safe,"loc(top(public()))"}
25+
26+
-doc="Library entry points not necessarily have to be referenced."
27+
-config=MC3R1.R2.1,declarations+={safe,"loc(top(public()))"}
28+
29+
-doc="Library entry points not necessarily have to be referenced in more than one translation units."
30+
-config=MC3R1.R8.7,declarations+={safe,"loc(top(public()))"}
31+
32+
-doc="Syscall declarations are automatically generated all with the extern qualifier. For the ones with internal linkage the use of the extern qualifier is a violation of rule 8.8."
33+
-config=MC3R1.R8.8,declarations={relied, "^z_vrfy_.*$||^z_impl_.*$"}
34+
35+
-doc="Function hash, that is automatically generated, does not use the parameter \"len\" in all its definitions."
36+
-config=MC3R1.R2.7,declarations+={relied,"context(^hash\\(const char\\*, size_t\\)$)&&name(len)"}
37+
38+
-doc="Function \"z_object_lookup\", that is automatically generated, uses single-statement bodies not enclosed in braces."
39+
-config=MC3R1.R15.6,reports={relied, "all_area(context(^z_object_lookup\\(const char\\*, size_t\\)$))"}
40+
41+
-doc="The following declarations are in generated files: not in all configuration they are implemented.
42+
Chainging the generators could be dangerous and the advantages in enforcing the rule do not outweight these dangers."
43+
-config=MC3R1.R8.6,declarations+={safe, "loc(top(file(^zephyr/build/zephyr/include/generated/.*$)))"}

cmake/sca/eclair/ECL/analysis.ecl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-project_name=getenv("ECLAIR_PROJECT_NAME")
2+
-project_root=getenv("ECLAIR_PROJECT_ROOT")
3+
-setq=data_dir,getenv("ECLAIR_DATA_DIR")
4+
-setq=set,getenv("ECLAIR_RULESET")
5+
6+
-enable=B.REPORT.ECB
7+
-config=B.REPORT.ECB,output=join_paths(data_dir,"FRAME.@[email protected]")
8+
-config=B.REPORT.ECB,preprocessed=show
9+
-config=B.REPORT.ECB,macros=10
10+
11+
-enable=B.EXPLAIN
12+
13+
-eval_file=toolchain.ecl
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file must be named analyze_<RULESET>.ecl, where <RULESET> is the first
2+
# argument of analyze.sh.
3+
#
4+
# The aim of this file is to define the analysis configuration for <RULESET>.
5+
#
6+
# The essential portions of this file are marked with "# NEEDED":
7+
# they may be adapted of course.
8+
9+
# Enable the desired metrics.
10+
-enable=MET.HIS.COMF
11+
-enable=MET.HIS.PATH
12+
-enable=MET.HIS.GOTO
13+
-enable=MET.HIS.v_G
14+
-enable=MET.HIS.CALLING
15+
-enable=MET.HIS.CALLS
16+
-enable=MET.HIS.PARAM
17+
-enable=MET.HIS.STMT
18+
-enable=MET.HIS.LEVEL
19+
-enable=MET.HIS.RETURN
20+
-enable=MET.HIS.VOCF
21+
-enable=MET.HIS.ap_cg_cycle
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# This file must be named analyze_<RULESET>.ecl, where <RULESET> is the first
2+
# argument of analyze.sh.
3+
#
4+
# The aim of this file is to define the analysis configuration for <RULESET>.
5+
#
6+
# The essential portions of this file are marked with "# NEEDED":
7+
# they may be adapted of course.
8+
9+
-eval_file=zephyr_common_config.ecl
10+
11+
-doc_begin="Selection of guidelines from
12+
https://docs.zephyrproject.org/latest/guides/coding_guidelines/index.html"
13+
-enable=MC3R1.D4.13
14+
-enable=MC3R1.D4.2
15+
-enable=MC3R1.D4.4
16+
-enable=MC3R1.D4.5
17+
-enable=MC3R1.D4.8
18+
-enable=MC3R1.D4.11
19+
-enable=MC3R1.D4.12
20+
-enable=MC3R1.D4.14
21+
-enable=MC3R1.D4.7
22+
-enable=MC3R1.R10.5
23+
-enable=MC3R1.R10.2
24+
-enable=MC3R1.R10.6
25+
-enable=MC3R1.R10.7
26+
-enable=MC3R1.R10.8
27+
-enable=MC3R1.R1.2
28+
-enable=MC3R1.R1.3
29+
-enable=MC3R1.R12.4
30+
-enable=MC3R1.R12.5
31+
-enable=MC3R1.R12.2
32+
-enable=MC3R1.R13.4
33+
-enable=MC3R1.R13.1
34+
-enable=MC3R1.R13.2
35+
-enable=MC3R1.R13.5
36+
-enable=MC3R1.R13.6
37+
-enable=MC3R1.R18.5
38+
-enable=MC3R1.R18.1
39+
-enable=MC3R1.R18.2
40+
-enable=MC3R1.R18.3
41+
-enable=MC3R1.R18.6
42+
-enable=MC3R1.R18.8
43+
-enable=MC3R1.R21.11
44+
-enable=MC3R1.R21.13
45+
-enable=MC3R1.R21.17
46+
-enable=MC3R1.R21.18
47+
-enable=MC3R1.R21.19
48+
-enable=MC3R1.R21.20
49+
-enable=MC3R1.R2.7
50+
-enable=MC3R1.R2.2
51+
-enable=MC3R1.R4.2
52+
-enable=MC3R1.R4.1
53+
-enable=MC3R1.R17.3
54+
-enable=MC3R1.R17.4
55+
-enable=MC3R1.R17.6
56+
-enable=MC3R1.R17.1
57+
-enable=MC3R1.R17.5
58+
-enable=MC3R1.R19.1
59+
-enable=MC3R1.R22.2
60+
-enable=MC3R1.R22.5
61+
-enable=MC3R1.R22.6
62+
-enable=MC3R1.R9.1
63+
-enable=MC3R1.R9.2
64+
-enable=MC3R1.R9.3
65+
-enable=MC3R1.R9.4
66+
-enable=MC3R1.R9.5
67+
-enable=MC3R1.D2.1
68+
-enable=MC3R1.R11.2
69+
-enable=MC3R1.R11.6
70+
-enable=MC3R1.R11.7
71+
-enable=MC3R1.R11.8
72+
-enable=MC3R1.R11.9
73+
-enable=MC3R1.R14.1
74+
-enable=MC3R1.R14.2
75+
-enable=MC3R1.R14.3
76+
-enable=MC3R1.R15.2
77+
-enable=MC3R1.R15.3
78+
-enable=MC3R1.R15.6
79+
-enable=MC3R1.R15.7
80+
-enable=MC3R1.R16.1
81+
-enable=MC3R1.R16.2
82+
-enable=MC3R1.R16.3
83+
-enable=MC3R1.R16.4
84+
-enable=MC3R1.R16.5
85+
-enable=MC3R1.R16.6
86+
-enable=MC3R1.R16.7
87+
-enable=MC3R1.R20.11
88+
-enable=MC3R1.R20.12
89+
-enable=MC3R1.R20.13
90+
-enable=MC3R1.R20.14
91+
-enable=MC3R1.R20.2
92+
-enable=MC3R1.R20.3
93+
-enable=MC3R1.R20.4
94+
-enable=MC3R1.R20.8
95+
-enable=MC3R1.R20.9
96+
-enable=MC3R1.R3.1
97+
-enable=MC3R1.R3.2
98+
-enable=MC3R1.R5.2
99+
-enable=MC3R1.R5.3
100+
-enable=MC3R1.R5.4
101+
-enable=MC3R1.R5.5
102+
-enable=MC3R1.R6.1
103+
-enable=MC3R1.R6.2
104+
-enable=MC3R1.R7.1
105+
-enable=MC3R1.R7.2
106+
-enable=MC3R1.R7.3
107+
-enable=MC3R1.R7.4
108+
-enable=MC3R1.R8.1
109+
-enable=MC3R1.R8.10
110+
-enable=MC3R1.R8.12
111+
-enable=MC3R1.R8.14
112+
-enable=MC3R1.R8.2
113+
-enable=MC3R1.R8.4
114+
-enable=MC3R1.R8.8
115+
-doc_end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file must be named analyze_<RULESET>.ecl, where <RULESET> is the first
2+
# argument of analyze.sh.
3+
#
4+
# The aim of this file is to define the analysis configuration for <RULESET>.
5+
#
6+
# The essential portions of this file are marked with "# NEEDED":
7+
# they may be adapted of course.
8+
9+
-eval_file=zephyr_common_config.ecl
10+
11+
-doc_begin="Selection of guidelines from
12+
https://docs.zephyrproject.org/latest/guides/coding_guidelines/index.html"
13+
-enable=MC3R1.R2.3
14+
-enable=MC3R1.R2.1
15+
-enable=MC3R1.R5.9
16+
-enable=MC3R1.R5.1
17+
-enable=MC3R1.R5.6
18+
-enable=MC3R1.R5.7
19+
-enable=MC3R1.R5.8
20+
-enable=MC3R1.R8.9
21+
-enable=MC3R1.R8.3
22+
-enable=MC3R1.R8.5
23+
-enable=MC3R1.R8.6
24+
-enable=MC3R1.R22.4
25+
-enable=MC3R1.R22.3
26+
-enable=MC3R1.D1.1
27+
-enable=MC3R1.D3.1
28+
-enable=MC3R1.D4.1
29+
-enable=MC3R1.D4.10
30+
-enable=MC3R1.R17.2
31+
-enable=MC3R1.R17.7
32+
-doc_end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file must be named analyze_<RULESET>.ecl, where <RULESET> is the first
2+
# argument of analyze.sh.
3+
#
4+
# The aim of this file is to define the analysis configuration for <RULESET>.
5+
#
6+
# The essential portions of this file are marked with "# NEEDED":
7+
# they may be adapted of course.
8+
9+
-eval_file=zephyr_common_config.ecl
10+
11+
-doc_begin="Selection of guidelines from
12+
https://docs.zephyrproject.org/latest/guides/coding_guidelines/index.html"
13+
-enable=MC3R1.R8.2
14+
-enable=MC3R1.R10.2
15+
-enable=MC3R1.R10.5
16+
-enable=MC3R1.R10.6
17+
-enable=MC3R1.R11.2
18+
-enable=MC3R1.R12.4
19+
-enable=MC3R1.R13.4
20+
-enable=MC3R1.R16.1
21+
-doc_end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This file must be named analyze_<RULESET>.ecl, where <RULESET> is the first
2+
# argument of analyze.sh.
3+
#
4+
# The aim of this file is to define the analysis configuration for <RULESET>.
5+
#
6+
# The essential portions of this file are marked with "# NEEDED":
7+
# they may be adapted of course.
8+
9+
-eval_file=zephyr_common_config.ecl
10+
11+
-doc_begin="Selection of guidelines from
12+
https://docs.zephyrproject.org/latest/guides/coding_guidelines/index.html"
13+
-enable=MC3R1.D4.6
14+
-enable=MC3R1.D4.9
15+
-enable=MC3R1.R12.1
16+
-enable=MC3R1.R13.3
17+
-enable=MC3R1.R2.6
18+
-enable=MC3R1.R10.1
19+
-enable=MC3R1.R10.3
20+
-enable=MC3R1.R10.4
21+
-enable=MC3R1.R14.4
22+
-enable=MC3R1.R20.7
23+
-doc_end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file must be named analyze_<RULESET>.ecl, where <RULESET> is the first
2+
# argument of analyze.sh.
3+
#
4+
# The aim of this file is to define the analysis configuration for <RULESET>.
5+
#
6+
# The essential portions of this file are marked with "# NEEDED":
7+
# they may be adapted of course.
8+
-eval_file=zephyr_common_config.ecl
9+
10+
-doc_begin="Selection of guidelines from
11+
https://docs.zephyrproject.org/latest/guides/coding_guidelines/index.html"
12+
-enable=MC3R1.R21.1
13+
-enable=MC3R1.R21.12
14+
-enable=MC3R1.R21.14
15+
-enable=MC3R1.R21.15
16+
-enable=MC3R1.R21.16
17+
-enable=MC3R1.R21.2
18+
-enable=MC3R1.R21.3
19+
-enable=MC3R1.R21.4
20+
-enable=MC3R1.R21.6
21+
-enable=MC3R1.R21.7
22+
-enable=MC3R1.R21.9
23+
-enable=MC3R1.R22.1
24+
-enable=MC3R1.R22.10
25+
-enable=MC3R1.R22.7
26+
-enable=MC3R1.R22.8
27+
-enable=MC3R1.R22.9
28+
-doc_end
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
-call_properties+={"name(z_phys_map)", {"pointee_read(1=never)","pointee_write(1=always)","taken()"}}
3+
-call_properties+={"name(pcie_get_mbar)", {"pointee_read(3=never)","pointee_write(3=maybe)","taken()"}}
4+
-call_properties+={"name(k_mem_region_align)", {
5+
"pointee_read(1..2=never)",
6+
"pointee_write(1..2=always)","taken()"
7+
}}
8+
-call_properties+={"name(pentry_get)", {
9+
"pointee_read(1..2=never&&3..4=always)",
10+
"pointee_write(1..2=maybe&&3..4=never)"
11+
}}
12+
-call_properties+={"name(z_phys_unmap)", {"pointee_read(1=never)","pointee_write(1=never)"}}
13+
-call_properties+={"name(check_sum)", {"pointee_read(1=always)","pointee_write(1=never)"}}
14+
-call_properties+={"name(z_impl_device_get_binding)", {"pointee_read(1=maybe)","pointee_write(1=maybe)","taken()"}}
15+
-call_properties+={"name(z_setup_new_thread)", {"pointee_read(10=maybe)","pointee_write(10=never)","taken()"}}
16+
-call_properties+={"name(mbox_message_put)", {"pointee_read(3=always)","pointee_write(3=always)"}}
17+
-doc_begin="The functions can be implemented using the GCC built-in functions.
18+
See Section \"6.62.13 6.56 Built-in Functions to Perform Arithmetic with Overflow Checking\" of "GCC_MANUAL"."
19+
-call_properties+={"name(size_mul_overflow)", {"pointee_read(3=never)","pointee_write(3=always)","taken()"}}
20+
-call_properties+={"name(size_add_overflow)", {"pointee_read(3=never)","pointee_write(3=always)","taken()"}}
21+
-call_properties+={"name(__builtin_mul_overflow)", {"pointee_read(3=never)","pointee_write(3=always)","taken()"}}
22+
-call_properties+={"name(__builtin_add_overflow)", {"pointee_read(3=never)","pointee_write(3=always)","taken()"}}
23+
-doc_end
24+
25+
-call_properties+={"name(__builtin_va_end)", {"taken()"}} # Not documented in gcc.pdf
26+
-call_properties+={"name(arch_page_phys_get)", {"pointee_read(2=never)","pointee_write(2=maybe)","taken()"}}
27+
-call_properties+={"name(cbvprintf)", {"taken()"}}
28+
-call_properties+={"name(cbvprintf)", {"taken()"}}
29+
-call_properties+={"name(char2hex)", {"pointee_read(2=never)","pointee_write(2=maybe)"}}
30+
-call_properties+={"name(find_and_stack)", {"pointee_read(3=never)","pointee_write(3=always)"}}
31+
-call_properties+={"name(fix_missing_black)", {"pointee_read(1=always)","pointee_write(1=maybe)"}}
32+
-call_properties+={"name(__get_cpuid)", {"pointee_read(2..5=never)","pointee_write(2..5=always)"}}
33+
-call_properties+={"name(k_mutex_init)", {"pointee_read(1=never)","pointee_write(1=always)"}}
34+
-call_properties+={"name(k_sem_init)", {"pointee_read(1=never)","pointee_write(1=maybe)"}}
35+
-call_properties+={"name(k_work_init)", {"pointee_read(1=never)","pointee_write(1=always)"}}
36+
-call_properties+={"name(k_work_init_delayable)", {"pointee_read(1=never)","pointee_write(1=always)"}}
37+
-call_properties+={"name(k_work_queue_start)", {"taken()"}}
38+
-call_properties+={"name(log_from_user)", {"pointee_write(1..=never)", "taken()"}}
39+
-call_properties+={"name(log_n)", {"taken()"}}
40+
-call_properties+={"name(log_string_sync)", {"pointee_write(1..=never)", "taken()"}}
41+
-call_properties+={"name(match_region)", {"pointee_read(5..6=never)","pointee_write(5=always&&6=maybe)"}}
42+
-call_properties+={"name(mbox_async_alloc)", {"pointee_read(1=never)","pointee_write(1=maybe)"}}
43+
-call_properties+={"name(pipe_xfer_prepare)", {"pointee_read(2=never)","pointee_write(2=always)"}}
44+
-call_properties+={"name(printk)", {"pointee_write(1..=never)", "taken()"}}
45+
-call_properties+={"name(snprintk)", {"pointee_read(1=never)","pointee_write(1=always)", "taken()"}} # to check
46+
-call_properties+={"name(snprintk)", {"taken()"}}
47+
-call_properties+={"name(sys_bitarray_alloc)", {"pointee_read(3=never)","pointee_write(3=maybe)","taken()"}}
48+
-call_properties+={"name(sys_slist_init)", {"pointee_read(1=never)","pointee_write(1=always)"}}
49+
-call_properties+={"name(vprintk)", {"taken()"}}
50+
-call_properties+={"name(z_dummy_thread_init)", {"pointee_read(1=never)","pointee_write(1=always)"}} # the function does not initialize all the fields
51+
-call_properties+={"name(z_impl_k_stack_pop)", {"taken()"}}
52+
-call_properties+={"name(z_impl_z_log_msg2_runtime_vcreate)", {"taken()"}}
53+
-call_properties+={"name(z_log_minimal_printk)", {"pointee_write(1..=never)", "taken()"}}
54+
-call_properties+={"name(z_log_msg2_runtime_create)", {"pointee_write(1..=never)", "taken()"}}
55+
-call_properties+={"name(z_log_printk)", {"taken()"}}
56+
-call_properties+={"name(z_log_printf_arg_checker)", {"pointee_write(1..=never)", "taken()"}}
57+
-call_properties+={"name(z_log_strdup)", {"taken()"}}
58+
-call_properties+={"name(z_rb_foreach_next)", {"taken()"}}
59+
-call_properties+={"name(z_user_string_copy)", {"pointee_read(1=never)","pointee_write(1=maybe)","taken()"}}
60+
61+
-doc_begin="These macros are designed to evaluate to either 0 or 1."
62+
-call_properties+={"macro(name(UTIL_NOT))",{"data_kind(0=int_bool)"}}
63+
-call_properties+={"macro(name(IS_ENABLED))",{"data_kind(0=int_bool)"}}
64+
-call_properties+={"decl(name(isspace))",{"data_kind(0=int_bool)"}}
65+
-call_properties+={"macro(name(isdigit))",{"data_kind(0=int_bool)"}}
66+
-call_properties+={"decl(name(isdigit))",{"data_kind(0=int_bool)"}}
67+
-call_properties+={"macro(name(isalpha))",{"data_kind(0=int_bool)"}}
68+
-call_properties+={"decl(name(isalpha))",{"data_kind(0=int_bool)"}}
69+
-call_properties+={"macro(name(isupper))",{"data_kind(0=int_bool)"}}
70+
-call_properties+={"decl(name(isupper))",{"data_kind(0=int_bool)"}}
71+
-doc_end
72+
73+
-doc="__builtin_alloca cannot interfere with other effects."
74+
-call_properties+={"decl(name(__builtin_alloca))",{"noeffect"}}
75+
76+
-doc="log_strdup cannot interfere with other effects."
77+
-call_properties+={"decl(name(log_strdup))",{"noeffect"}}
78+
79+
80+
# Not documented functions
81+
# device_map

0 commit comments

Comments
 (0)