]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: remove pointless static variable in uid.c
authorStefan Metzmacher <metze@samba.org>
Thu, 8 Jan 2009 08:04:30 +0000 (09:04 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 8 Jan 2009 11:22:19 +0000 (12:22 +0100)
We always free the value at the end of the function,
so we don't need a static variable to hold just NULL
for the time the function isn't executed.

metze

source3/smbd/uid.c

index 5a4b8a52e791bb8a65a802bb765bba72b13c31fb..82204e97e972c3ae7c1d64812c7f49244065ee3e 100644 (file)
@@ -28,13 +28,11 @@ extern struct current_user current_user;
 
 bool change_to_guest(void)
 {
-       static struct passwd *pass=NULL;
+       struct passwd *pass;
 
+       pass = getpwnam_alloc(talloc_autofree_context(), lp_guestaccount());
        if (!pass) {
-               /* Don't need to free() this as its stored in a static */
-               pass = getpwnam_alloc(talloc_autofree_context(), lp_guestaccount());
-               if (!pass)
-                       return(False);
+               return false;
        }
 
 #ifdef AIX
@@ -49,9 +47,8 @@ bool change_to_guest(void)
        current_user.vuid = UID_FIELD_INVALID;
 
        TALLOC_FREE(pass);
-       pass = NULL;
 
-       return True;
+       return true;
 }
 
 /*******************************************************************