[PATCH] make signal.c more readable (was: Re: xor as a lazy comparison)

Steven Rostedt
2005-07-25T18:00:46Z

Sorry for the double post. I added [PATCH] and changed the subject, and added Linus.

On Mon, 2005-07-25 at 10:57 +0200, Bernd Petrovitsch wrote:
> On Sun, 2005-07-24 at 18:15 -0400, Puneet Vyas wrote:
> [...]
> > I just compiled two identical program , one with "!=" and other with
> > "^". The assembly output is identical.
>
> Hmm, which compiler and which version?
> You might want to try much older and other compilers.
>

Doesn't matter. The cycles saved for old compilers is not rational to
have obfuscated code.

Here's the patch to make the code more readable.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

--- linux-2.6.13-rc3/kernel/signal.c.orig 2005-07-25 13:50:20.000000000 -0400
+++ linux-2.6.13-rc3/kernel/signal.c 2005-07-25 13:50:51.000000000 -0400
@@ -665,8 +665,8 @@ static int check_kill_permission(int sig
(unsigned long)info != 2 && SI_FROMUSER(info)))
&& ((sig != SIGCONT) ||
(current->signal->session != t->signal->session))
- && (current->euid ^ t->suid) && (current->euid ^ t->uid)
- && (current->uid ^ t->suid) && (current->uid ^ t->uid)
+ && (current->euid != t->suid) && (current->euid != t->uid)
+ && (current->uid != t->suid) && (current->uid != t->uid)
&& !capable(CAP_KILL))
return error;