coccinelle: automatically rewrite memset() to zero() or memzero() where we can

We are pretty good at this already, hence only a single case is actually
found by this.
This commit is contained in:
Lennart Poettering 2017-12-14 19:47:46 +01:00
parent fbd0b64f44
commit 673192494c
2 changed files with 31 additions and 1 deletions

30
coccinelle/memzero.cocci Normal file
View File

@ -0,0 +1,30 @@
@@
expression s;
@@
- memset(&s, 0, sizeof(s))
+ zero(s)
@@
expression s;
@@
- memset(s, 0, sizeof(*s))
+ zero(*s)
@@
expression s;
@@
- bzero(&s, sizeof(s))
+ zero(s)
@@
expression s;
@@
- bzero(s, sizeof(*s))
+ zero(*s)
@@
expression a, b;
@@
- memset(a, 0, b)
+ memzero(a, b)
@@
expression a, b;
@@
- bzero(a, b)
+ memzero(a, b)

View File

@ -133,7 +133,7 @@ static int determine_path_usage(Server *s, const char *path, uint64_t *ret_used,
}
static void cache_space_invalidate(JournalStorageSpace *space) {
memset(space, 0, sizeof(*space));
zero(*space);
}
static int cache_space_refresh(Server *s, JournalStorage *storage) {