mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: if (a & X || b & ~Y) in dasd.c
@ 2001-11-09 10:29 Carsten Otte
  0 siblings, 0 replies; 8+ messages in thread
From: Carsten Otte @ 2001-11-09 10:29 UTC (permalink / raw)
  To: Kevin; +Cc: Pete Zaitcev, linux-kernel, BOEBLINGEN LINUX390

Hi Pete, Hi Kevin,

it's just like Kevin explained, the singe &/|/~ are bit operations
while &&/|| are logical operations. The bit operations are handled
before the logical ones (am I correct?)- so compiler-wise this should
be fine.
Sure, one should use some paranthesises to make things clearer,
but why are you examining  such ancient code? 2.2.14. seems a little
bit historical for me. The current dasd device driver is much more
readable and better designed (is redesigned in the 2.4 series).

mit freundlichem Gruß / with kind regards
Carsten Otte

IBM Deutschland Entwicklung GmbH
Linux for 390/zSeries Development - Device Driver Team
Phone: +49/07031/16-4076
IBM internal phone: *120-4076
--
We are Linux.
Resistance indicates that you're missing the point!


Kevin <kevin@pheared.net> on 11/08/2001 10:10:51 PM

Please respond to Kevin <kevin@pheared.net>

To:   Pete Zaitcev <zaitcev@redhat.com>
cc:   Carsten Otte/Germany/IBM@IBMDE, <linux-kernel@vger.kernel.org>,
      BOEBLINGEN LINUX390/Germany/IBM@IBMDE
Subject:  Re: if (a & X || b & ~Y) in dasd.c



On Thu, 8 Nov 2001, Pete Zaitcev wrote:

[zaitce] Date: Thu, 8 Nov 2001 15:57:49 -0500
[zaitce] From: Pete Zaitcev <zaitcev@redhat.com>
[zaitce] To: Cotte@de.ibm.com
[zaitce] Cc: linux-kernel@vger.kernel.org, Linux390@de.ibm.com
[zaitce] Subject: if (a & X || b & ~Y) in dasd.c
[zaitce]
[zaitce] Carsten and others:
[zaitce]
[zaitce] this code in 2.2.14 looks suspicious to me:
[zaitce]
[zaitce] ./drivers/s390/block/dasd.c:
[zaitce]         /* first of all lets try to find out the appropriate
era_action */
[zaitce]         if (stat->flag & DEVSTAT_FLAG_SENSE_AVAIL ||
[zaitce]             stat->dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END))
{
[zaitce]                 /* anything abnormal ? */
[zaitce]                 if (device->discipline->examine_error == NULL ||
[zaitce]                     stat->flag & DEVSTAT_HALT_FUNCTION) {
[zaitce]                         era = dasd_era_fatal;
[zaitce]                 } else {
[zaitce]                         era = device->discipline->examine_error
(cqr, stat);
[zaitce]                 }
[zaitce]                 DASD_DRIVER_DEBUG_EVENT (1, dasd_int_handler,"
era_code %d",
[zaitce]                                          era);
[zaitce]         }
[zaitce]
[zaitce] Are you sure any parenthesises are not needed here?

I'm not going to pretend to know what the code is accomplishing, but as
a matter of C, those &'s aren't the same as &&'s and will get executed as
the || is tested.  So the first one will get &'ded and if false then the
second will and if neither return true then we move on.

Or, perhaps I'm being an idiot and misunderstanding the question and the
code.  In that case, I'll pretend I didn't say anything.  :)

-[ kevin@pheared.net                 devel.pheared.net ]-
-[ Rather be forgotten, than remembered for giving in. ]-
-[ ZZ = g ^ (xb * xa) mod p      g = h^{(p-1)/q} mod p ]-






^ permalink raw reply	[flat|nested] 8+ messages in thread
* if (a & X || b & ~Y) in dasd.c
@ 2001-11-08 20:57 Pete Zaitcev
  2001-11-08 21:10 ` Kevin
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Pete Zaitcev @ 2001-11-08 20:57 UTC (permalink / raw)
  To: Cotte; +Cc: linux-kernel, Linux390

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 ||
            stat->dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) {
                /* anything abnormal ? */
                if (device->discipline->examine_error == NULL ||
                    stat->flag & DEVSTAT_HALT_FUNCTION) {
                        era = dasd_era_fatal;
                } else {
                        era = device->discipline->examine_error (cqr, stat);
                }
                DASD_DRIVER_DEBUG_EVENT (1, dasd_int_handler," era_code %d",
                                         era);
        }

Are you sure any parenthesises are not needed here?

-- Pete

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-11-21  7:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-09 10:29 if (a & X || b & ~Y) in dasd.c Carsten Otte
  -- strict thread matches above, loose matches on Subject: below --
2001-11-08 20:57 Pete Zaitcev
2001-11-08 21:10 ` Kevin
2001-11-08 21:18 ` Jonathan Lundell
2001-11-08 21:28 ` Richard B. Johnson
2001-11-19 18:40 ` bill davidsen
2001-11-19 19:38   ` Peter T. Breuer
2001-11-21  6:57   ` Stevie O

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®