mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-23 14:02:56 +00:00
DEV: coccinelle: Add xalloc_size.cocci
This commits the Coccinelle patch to clean up sizeof handling for malloc/calloc.
This commit is contained in:
parent
16554245e2
commit
63ee0e4c01
41
dev/coccinelle/xalloc_size.cocci
Normal file
41
dev/coccinelle/xalloc_size.cocci
Normal file
@ -0,0 +1,41 @@
|
||||
@@
|
||||
type T;
|
||||
expression E;
|
||||
expression t;
|
||||
@@
|
||||
|
||||
(
|
||||
t = calloc(E, sizeof(*t))
|
||||
|
|
||||
- t = calloc(E, sizeof(T))
|
||||
+ t = calloc(E, sizeof(*t))
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *x;
|
||||
@@
|
||||
|
||||
x = malloc(
|
||||
- sizeof(T)
|
||||
+ sizeof(*x)
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *x;
|
||||
@@
|
||||
|
||||
x = calloc(1,
|
||||
- sizeof(T)
|
||||
+ sizeof(*x)
|
||||
)
|
||||
|
||||
@@
|
||||
@@
|
||||
|
||||
calloc(
|
||||
+ 1,
|
||||
...
|
||||
- ,1
|
||||
)
|
Loading…
Reference in New Issue
Block a user