Re: drivers/char/sysrq.c

From: J.A. Magallon (jamagallon@able.es)
Date: Fri May 30 2003 - 10:16:32 EST



On 05.30, Jörn Engel wrote:
> On Fri, 30 May 2003 16:44:55 +0200, Margit Schubert-While wrote:
> >
> > In drivers/char/sysrq.c (2.4 and 2.5) we have :
> >
> > if ((key >= '0') & (key <= '9')) {
> > retval = key - '0';
> > } else if ((key >= 'a') & (key <= 'z')) {
> >
> > Shouldn't the "&" be (pedantically) "&&" ?
>
> It is semantically the same. If you can show that gcc optimization
> also creates the same assembler code, few people will object to a
> patch.
>

I see a diff:
- & is bitwise and you always perform the op
- && is logical and gcc must shortcut it

I think people use & 'cause they prefer the extra argument calculation
than the branch for the shortcut (AFAIR...)

or not ?

--
J.A. Magallon <jamagallon@xxxxxxx> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.21-rc6-jam1 (gcc 3.2.3 (Mandrake Linux 9.2 3.2.3-1mdk))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/