Re: if (a & X || b & ~Y) in dasd.c

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Thu Nov 08 2001 - 16:28:14 EST


On Thu, 8 Nov 2001, Pete Zaitcev wrote:

It looks okay, but it sure is hard to read. I will simplify...

> Carsten and others:
>
> this code in 2.2.14 looks suspicious to me:
>
> ./drivers/s390/block/dasd.c:
> /* first of all lets try to find out the appropriate era_action */
> if (stat->flag & DEVSTAT_FLAG_SENSE_AVAIL ||

          if (value & MASK ||

> stat->dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) {

              another_value & ANOTHER_MASK )

                (if ether of these are TRUE)

... etc.
 Don't confuse & with &&....

> Are you sure any parenthesises are not needed here?

No, but they sure would help to make the code readable by humans
as well as compilers.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

    I was going to compile a list of innovations that could be
    attributed to Microsoft. Once I realized that Ctrl-Alt-Del
    was handled in the BIOS, I found that there aren't any.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Nov 15 2001 - 21:00:19 EST