From owner-freebsd-current Mon Feb 11 19:29:16 2002 Delivered-To: freebsd-current@freebsd.org Received: from newman2.bestweb.net (newman2.bestweb.net [209.94.102.67]) by hub.freebsd.org (Postfix) with ESMTP id 4E69E37B619; Mon, 11 Feb 2002 18:18:25 -0800 (PST) Received: from okeeffe.bestweb.net (okeefe.bestweb.net [209.94.100.110]) by newman2.bestweb.net (Postfix) with ESMTP id B1E332303D; Mon, 11 Feb 2002 21:17:42 -0500 (EST) Received: by okeeffe.bestweb.net (Postfix, from userid 0) id 149F59F134; Mon, 11 Feb 2002 21:12:27 -0500 (EST) Date: Sun, 10 Feb 2002 01:27:25 +1100 (EST) From: Bruce Evans To: Julian Elischer Cc: John Baldwin , Subject: Re: cred stuff.. Message-Id: <20020212021227.149F59F134@okeeffe.bestweb.net> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 8 Feb 2002, Julian Elischer wrote: > I'd like to commit the code to keep the ucred across userland, > with the code to clear it to NULL kept under DEBUG ifdefs. > > i.e. > > > in trap(), ast() and syscall() > > > > if (td->td_ucred != p->p_ucred) { > > PROC_LOCK(p); > > if (td->td_ucred) { > > crfree(td->td_ucred); > > td->td_ucred = NULL; > > } > > if (p->p_ucred != NULL) { > > td->td_ucred = crhold(p->p_ucred); > > } > > PROC_UNLOCK(p); > > } Please fix the style bugs in this before committing: - explicit NULL in only one null pointer checks - excessive braces for one of the ifs. > and in userret() and ast() > > >#ifdef DEBUG /*your choice of variable here*/ > > PROC_LOCK(p); > > if (td->td_ucred) { > > crfree(td->td_ucred); > > td->td_ucred = NULL; > > } > > PROC_UNLOCK(p); > >#endif I think this is better left where it is in the functions that aquire the locks. It can then be done unconditionally, and not in a loop. The style of the null pointer check in this is bug for bug compatible with the corresponding one above. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message