Subject: Re: commoning up code that changes uids and gids
To: David Laight <david@l8s.co.uk>
From: Luke Mewburn <lukem@netbsd.org>
List: tech-kern
Date: 03/27/2003 22:32:23
On Sun, Mar 09, 2003 at 07:19:29PM +0000, David Laight wrote:
  | > Also, you didn't adress the issue I raised - that ruid
  | > in sys_setreuid() is always set to as 'p->p_cred->p_ruid ? -1 : euid;',
  | > so the previous 'if (ruid == -1) ruid = p->p_cred->p_ruid;' has
  | > no effect. Other routines might have similar issues.
  | 
  | svuid = ruid == p->p_cred->p_ruid ? -1 : euid;
  | 
  | Is an assignment to svuid, not ruid.

Seeing as this did cause more confusion that it's worth, could you
just add a couple of parenthesis.  E.g;
	svuid = (ruid == p->p_cred->p_ruid ? -1 : euid);
or
	svuid = (ruid == p->p_cred->p_ruid) ? -1 : euid;


[Per /usr/share/misc/style:
	* Don't excessively use parenthesis, but they should be used if
	* statement is really confusing without them [...]
Your existing code did cause confusion.  I had to read Jaromir's query
a couple of times to double check that you were doing the right thing;
had the parens been there it would have been much more obvious :]