Re: [PATCH] Added support for dropping privileges to git-daemon.
- From
- Mitchell Blank Jr <mitch@sfgoth.com>
- Date
- Aug 19, 2006, 17:15 UTC
- Message-ID
- <20060819171534.GA64962@gaz.sfgoth.com>
- In-Reply-To
- <e5bfff550608190819i3cade548g28b2c95fab172a49@mail.gmail.com>
Marco Costalba wrote:
Show 6 quoted lines
> >> >+ if (!user ^ !group)
> >> >+ die("either set both user and group or none of them");
>
> BTW the following (very ugly) works.
>
> if ((int)user ^ (int)group)No it doesn't. Besides being a dangerous cast (no guarantee that a pointer will fit in an "int") your code is basically just a fancy way of saying
if (user != group)
Which is definitely NOT what is intended. "user" and "group" are pointers -- unless they're both NULL we expect them to have different values. The original code is equivalent to:
if ((user == NULL) != (group == NULL))
which is what is actually intended.
-Mitch