|
11 | 11 | if "ZEPHYR_BASE" not in os.environ:
|
12 | 12 | exit("$ZEPHYR_BASE environment variable undefined.")
|
13 | 13 |
|
14 |
| -coccinelle_scripts = ["/scripts/coccinelle/reserved_names.cocci", |
| 14 | +RESERVED_NAMES_SCRIPT = "/scripts/coccinelle/reserved_names.cocci" |
| 15 | + |
| 16 | +coccinelle_scripts = [RESERVED_NAMES_SCRIPT, |
15 | 17 | "/scripts/coccinelle/same_identifier.cocci",
|
16 | 18 | #"/scripts/coccinelle/identifier_length.cocci",
|
17 | 19 | ]
|
18 | 20 |
|
| 21 | +coccinelle_reserved_names_exclude_regex = [ |
| 22 | + r"lib/libc/.*", |
| 23 | + r"lib/posix/.*", |
| 24 | + r"include/zephyr/posix/.*", |
| 25 | +] |
19 | 26 |
|
20 | 27 | def parse_coccinelle(contents: str, violations: dict):
|
21 | 28 | reg = re.compile("([a-zA-Z0-9_/]*\\.[ch]:[0-9]*)(:[0-9\\-]*: )(.*)")
|
@@ -69,7 +76,18 @@ def main():
|
69 | 76 | continue
|
70 | 77 |
|
71 | 78 | for script in coccinelle_scripts:
|
72 |
| - script_path = os.getenv("ZEPHYR_BASE") + "/" + script |
| 79 | + |
| 80 | + skip_reserved_names = False |
| 81 | + if script == RESERVED_NAMES_SCRIPT: |
| 82 | + for path in coccinelle_reserved_names_exclude_regex: |
| 83 | + if re.match(path, f.path): |
| 84 | + skip_reserved_names = True |
| 85 | + break |
| 86 | + |
| 87 | + if skip_reserved_names: |
| 88 | + continue |
| 89 | + |
| 90 | + script_path =zephyr_base + "/" + script |
73 | 91 | print(f"Running {script} on {f.path}")
|
74 | 92 | try:
|
75 | 93 | cocci = sh.coccicheck(
|
|
0 commit comments