Subject: Re: commoning up code that changes uids and gids
To: David Laight <david@l8s.co.uk>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 04/05/2003 14:46:23
[ On Saturday, April 5, 2003 at 19:35:53 (+0100), David Laight wrote: ]
> Subject: Re: commoning up code that changes uids and gids
>
> > > svuid = (ruid == p->p_cred->p_ruid) ? -1 : euid;
>
> That use of () is particularly misleading,
I for one certainly don't think so.... (the original was arguably OK,
but the first suggested alternate that I've purposefully deleted from
above was potentially misleading to me)
> for instance how would you
> read:
>
> svuid = 1 + (ruid == p->p_cred->p_ruid) ? -1 : euid;
Now _that_ one is potentially misleading, or at least "hard" to read
without extra parens. ;-)
In the spirit of showing off the separate parts of the expression I
would write it as:
svuid = 1 + ((ruid == p->p_cred->p_ruid) ? -1 : euid);
(though I don't think I've ever even seen an example quite like that,
never mind writing one, even though I am a huge fan of "?:" expressions)
--
Greg A. Woods
+1 416 218-0098; <g.a.woods@ieee.org>; <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>