lib: Simplify copy_unix_token()
authorVolker Lendecke <vl@samba.org>
Fri, 2 Feb 2024 14:14:33 +0000 (15:14 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 12 Mar 2024 13:31:31 +0000 (13:31 +0000)
Avoid an else with implicit NULL initialization

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/lib/util.c

index b840221f41a7c4b685f9a08dc49c4a9bd8e21523..d0af82cd986a8b48682c53afdc021856f41d13dd 100644 (file)
@@ -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;
 }