Merge pull request #6179 from ton31337/fix/typecast_to_biger_sizes

tools: Add coccinelle script to catch typecasts to larger sizes
This commit is contained in:
Quentin Young 2020-04-07 12:42:38 -04:00 committed by GitHub
commit d9dc3b67a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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")