Merge pull request #7644 from poettering/memzero

add memzero()/zero() coccinelle scripts and use them
This commit is contained in:
Lennart Poettering
2017-12-15 10:27:31 +01:00
committed by GitHub
3 changed files with 34 additions and 2 deletions
+30
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)
+1 -1
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) {
+3 -1
View File
@@ -171,7 +171,7 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
link->port = _NET_DEV_PORT_INVALID;
link->autonegotiation = -1;
memset(&link->features, -1, sizeof(link->features));
memset(&link->features, 0xFF, sizeof(link->features));
r = config_parse(NULL, filename, file,
"Match\0Link\0Ethernet\0",
@@ -186,6 +186,8 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
return -ERANGE;
link->filename = strdup(filename);
if (!link->filename)
return log_oom();
LIST_PREPEND(links, ctx->links, link);
link = NULL;