From 97b11eedff9d2e17101ad453caf9e48b73246719 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 31 Jul 2015 19:56:38 +0200 Subject: tree-wide: introduce mfree() Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar); --- src/sysusers/sysusers.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'src/sysusers/sysusers.c') diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index b3fa29b84c..3a92d120d2 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -704,8 +704,7 @@ static int write_files(void) { goto finish; } - free(group_tmp); - group_tmp = NULL; + group_tmp = mfree(group_tmp); } if (gshadow) { if (rename(gshadow_tmp, gshadow_path) < 0) { @@ -713,8 +712,7 @@ static int write_files(void) { goto finish; } - free(gshadow_tmp); - gshadow_tmp = NULL; + gshadow_tmp = mfree(gshadow_tmp); } } @@ -724,8 +722,7 @@ static int write_files(void) { goto finish; } - free(passwd_tmp); - passwd_tmp = NULL; + passwd_tmp = mfree(passwd_tmp); } if (shadow) { if (rename(shadow_tmp, shadow_path) < 0) { @@ -733,8 +730,7 @@ static int write_files(void) { goto finish; } - free(shadow_tmp); - shadow_tmp = NULL; + shadow_tmp = mfree(shadow_tmp); } r = 0; @@ -1410,10 +1406,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } /* Verify name */ - if (isempty(name) || streq(name, "-")) { - free(name); - name = NULL; - } + if (isempty(name) || streq(name, "-")) + name = mfree(name); if (name) { r = specifier_printf(name, specifier_table, NULL, &resolved_name); @@ -1429,10 +1423,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } /* Verify id */ - if (isempty(id) || streq(id, "-")) { - free(id); - id = NULL; - } + if (isempty(id) || streq(id, "-")) + id = mfree(id); if (id) { r = specifier_printf(id, specifier_table, NULL, &resolved_id); @@ -1443,10 +1435,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } /* Verify description */ - if (isempty(description) || streq(description, "-")) { - free(description); - description = NULL; - } + if (isempty(description) || streq(description, "-")) + description = mfree(description); if (description) { if (!valid_gecos(description)) { @@ -1456,10 +1446,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } /* Verify home */ - if (isempty(home) || streq(home, "-")) { - free(home); - home = NULL; - } + if (isempty(home) || streq(home, "-")) + home = mfree(home); if (home) { if (!valid_home(home)) { -- cgit v1.2.3-54-g00ecf