diff options
| author | Quentin Young <qlyoung@users.noreply.github.com> | 2020-04-07 12:42:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-07 12:42:38 -0400 |
| commit | d9dc3b67a9284cc6a15fe1003d20187fa1fe1a0f (patch) | |
| tree | f09ef0c72b9bf3c71bc6aec29a172bbaabcf4257 | |
| parent | f3fafda47408787a5d4621d40e2fe095b8182016 (diff) | |
| parent | 71abb5c1353c1ad0ec470734d1b341ac6e06329f (diff) | |
Merge pull request #6179 from ton31337/fix/typecast_to_biger_sizes
tools: Add coccinelle script to catch typecasts to larger sizes
| -rw-r--r-- | tools/coccinelle/cast_to_larger_sizes.cocci | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/coccinelle/cast_to_larger_sizes.cocci b/tools/coccinelle/cast_to_larger_sizes.cocci new file mode 100644 index 0000000000..d97e1f9c33 --- /dev/null +++ b/tools/coccinelle/cast_to_larger_sizes.cocci @@ -0,0 +1,20 @@ +// spatch -sp_file tools/coccinelle/cast_to_larger_sizes.cocci --recursive-includes ./ + +@r@ +typedef uint8_t; +typedef uint16_t; +typedef uint32_t; +typedef uint64_t; +uint8_t *i8; +position p; +@@ + + \( + (uint64_t *) i8@p\|(uint32_t *) i8@p\|(uint16_t *) i8@p + \) + +@script:python@ +p << r.p; +@@ + +coccilib.report.print_report(p[0],"Bad typecast to larger size") |
