diff --git a/coccinelle/memzero.cocci b/coccinelle/memzero.cocci new file mode 100644 index 00000000000..ebdc3f6a2a9 --- /dev/null +++ b/coccinelle/memzero.cocci @@ -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) diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 48375f9c3ea..d68e3a8d519 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -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) {