Subject: Re: kern/3963: flags is already B_READ or B_WRITE
To: None <gnats-bugs@gnats.netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 08/11/1997 08:30:43
> in physio(), flags is initialised thus:
>         flags &= B_READ | B_WRITE;

> and then used:
>                                      (flags == B_READ) ? B_WRITE : B_READ))
> This usage can become:
>                                      uio->uio_iov[i].iov_len, flags))

(a) No, because the ?: construction interchanges B_READ and B_WRITE;

(b) No, because flags might have both bits or neither bit set (in
general, that is; in this particular case, B_WRITE is 0, so there are
only two states, not the four there at first appear to be).

What would work, and would probably be faster if bit-twiddling is
faster than a conditional branch, would be "flags ^ (B_READ|B_WRITE)".

Of course, the gain would be very marginal, so tiny that the code
opacity factor would probably outweigh the speed benefit.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B