mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 19:39:28 +00:00
tools: Add coccinelle script to catch typecasts to larger sizes
That's valid only for uint*_t Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
6b1d9f37ec
commit
71abb5c135
20
tools/coccinelle/cast_to_larger_sizes.cocci
Normal file
20
tools/coccinelle/cast_to_larger_sizes.cocci
Normal 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")
|
Loading…
Reference in New Issue
Block a user