mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 18:19:42 +00:00
Add semantic patch to NULL the destroyed pointer early
Our destroy functions usually look like this: void foo_destroy(foo_t **foop) { foo_t foo = *foop; ...destroy the contents of foo... *foop = NULL; } nulling the pointer should be done as soon as possible which is not always the case. This commit adds simple semantic patch that changes the example function to: void foo_destroy(foo_t **foop) { foo_t foo = *foop; *foop = NULL; ...destroy the contents of foo... }
This commit is contained in:
parent
d4f7603af2
commit
b97d003033
21
cocci/null-the-pointer-early.spatch
Normal file
21
cocci/null-the-pointer-early.spatch
Normal file
@ -0,0 +1,21 @@
|
||||
@@
|
||||
type T;
|
||||
T **PP;
|
||||
T *P;
|
||||
@@
|
||||
|
||||
P = *PP;
|
||||
+ *PP = NULL;
|
||||
...
|
||||
- *PP = NULL;
|
||||
|
||||
@@
|
||||
type T;
|
||||
identifier PP;
|
||||
identifier P;
|
||||
@@
|
||||
|
||||
T *P = *PP;
|
||||
+ *PP = NULL;
|
||||
...
|
||||
- *PP = NULL;
|
Loading…
x
Reference in New Issue
Block a user