From: Volker Lendecke Date: Fri, 2 Feb 2024 14:14:33 +0000 (+0100) Subject: lib: Simplify copy_unix_token() X-Git-Tag: tdb-1.4.11~1494 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32ecf1fe607f0442511189cb6639d405cb5125df;p=thirdparty%2Fsamba.git lib: Simplify copy_unix_token() Avoid an else with implicit NULL initialization Signed-off-by: Volker Lendecke Reviewed-by: Andrew Bartlett --- diff --git a/source3/lib/util.c b/source3/lib/util.c index b840221f41a..d0af82cd986 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1902,9 +1902,12 @@ struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct securi return NULL; } - cpy->uid = tok->uid; - cpy->gid = tok->gid; - cpy->ngroups = tok->ngroups; + *cpy = (struct security_unix_token){ + .uid = tok->uid, + .gid = tok->gid, + .ngroups = tok->ngroups, + }; + if (tok->ngroups) { /* Make this a talloc child of cpy. */ cpy->groups = (gid_t *)talloc_memdup( @@ -1913,8 +1916,6 @@ struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct securi TALLOC_FREE(cpy); return NULL; } - } else { - cpy->groups = NULL; } return cpy; }