From: Christian Brauner Date: Tue, 19 Feb 2019 22:48:06 +0000 (+0100) Subject: conf: cleanup macros get{g,u}name X-Git-Tag: lxc-3.2.0~132^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f410b2ae8218e82b8a20a1d956da909b37f524f;p=thirdparty%2Flxc.git conf: cleanup macros get{g,u}name Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 7bdd794c7..f089679ba 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -4597,10 +4597,9 @@ on_error: /* not thread-safe, do not use from api without first forking */ static char *getuname(void) { + __do_free char *buf = NULL; struct passwd pwent; struct passwd *pwentp = NULL; - char *buf; - char *username; size_t bufsize; int ret; @@ -4618,23 +4617,18 @@ static char *getuname(void) WARN("Could not find matched password record."); ERROR("Failed to get password record - %u", geteuid()); - free(buf); return NULL; } - username = strdup(pwent.pw_name); - free(buf); - - return username; + return strdup(pwent.pw_name); } /* not thread-safe, do not use from api without first forking */ static char *getgname(void) { + __do_free char *buf = NULL; struct group grent; struct group *grentp = NULL; - char *buf; - char *grname; size_t bufsize; int ret; @@ -4652,14 +4646,10 @@ static char *getgname(void) WARN("Could not find matched group record"); ERROR("Failed to get group record - %u", getegid()); - free(buf); return NULL; } - grname = strdup(grent.gr_name); - free(buf); - - return grname; + return strdup(grent.gr_name); } /* not thread-safe, do not use from api without first forking */