mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-01 09:08:06 +00:00
tool/misc: cocci script for if (ptr) operations, (void) memcpy
This commit is contained in:
parent
c10be05f57
commit
9f4d1a7b89
40
tool/misc/fix_null_pointer_checks.cocci
Normal file
40
tool/misc/fix_null_pointer_checks.cocci
Normal file
@ -0,0 +1,40 @@
|
||||
// Replace pointer null checks with boolen operations
|
||||
// inverse version of https://github.com/neomutt/coccinelle/blob/master/null-check.cocci
|
||||
// License: GPLv2
|
||||
|
||||
@@
|
||||
type T;
|
||||
identifier I;
|
||||
statement S1, S2;
|
||||
expression E;
|
||||
@@
|
||||
|
||||
T *I;
|
||||
|
||||
(
|
||||
- if (!I)
|
||||
+ if (I == NULL)
|
||||
S1
|
||||
|
|
||||
- if (I)
|
||||
+ if (I != NULL)
|
||||
S1
|
||||
|
|
||||
- if (!I)
|
||||
+ if (I == NULL)
|
||||
S1 else S2
|
||||
|
|
||||
- if (I)
|
||||
+ if (I != NULL)
|
||||
S1 else S2
|
||||
|
|
||||
if (E) S1 else
|
||||
- if (!I)
|
||||
+ if (I == NULL)
|
||||
S1 else S2
|
||||
|
|
||||
if (E) S1 else
|
||||
- if (I)
|
||||
+ if (I != NULL)
|
||||
S1 else S2
|
||||
)
|
6
tool/misc/ignore_return_mempcy.cocci
Normal file
6
tool/misc/ignore_return_mempcy.cocci
Normal file
@ -0,0 +1,6 @@
|
||||
// Ignore memcpy return
|
||||
@@
|
||||
expression E1, E2, E3;
|
||||
@@
|
||||
- memcpy(E1, E2, E3)
|
||||
+ (void) memcpy(E1, E2, E3)
|
Loading…
Reference in New Issue
Block a user