From: Vojtech Pavlik <vojtech@suse.cz>
To: Hugh Dickins <hugh@veritas.com>
Cc: Andre Hedrick <andre@linux-ide.org>,
Pozsar Balazs <pozsy@sch.bme.hu>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [IDE] meaningless #ifndef?
Date: Tue, 20 Feb 2001 19:20:56 +0100 [thread overview]
Message-ID: <20010220192056.A6846@suse.cz> (raw)
In-Reply-To: <Pine.LNX.4.21.0102201705280.11260-100000@alloc> <Pine.LNX.4.21.0102201730260.1046-100000@localhost.localdomain>
In-Reply-To: <Pine.LNX.4.21.0102201730260.1046-100000@localhost.localdomain>; from hugh@veritas.com on Tue, Feb 20, 2001 at 05:45:52PM +0000
On Tue, Feb 20, 2001 at 05:45:52PM +0000, Hugh Dickins wrote:
> >
> > > from drivers/ide/ide-features.c:
> > >
> > > /*
> > > * All hosts that use the 80c ribbon mus use!
> > > */
> > > byte eighty_ninty_three (ide_drive_t *drive)
> > > {
> > > return ((byte) ((HWIF(drive)->udma_four) &&
> > > #ifndef CONFIG_IDEDMA_IVB
> > > (drive->id->hw_config & 0x4000) &&
> > > #endif /* CONFIG_IDEDMA_IVB */
> > > (drive->id->hw_config & 0x6000)) ? 1 : 0);
> > > }
> > >
> > > If i see well, then this is always same whether CONFIG_IDEDMA_IVB is
> > > defined or not.
> > > What's the clue?
> > The first is true only if bit 14 is set.
> > The second is true if either bit 13 or 14 is set.
> >
> > Togather they test for two bits.
> > The first test is exclusive to bit 14
> > The second test is inclusive of bits 13 and 14.
> Andre, please read through that code again, and through your reply.
> It seems to me that Poszar is absolutely right, and your reply is
> (once again) just saying "there's lots of confusion out there, so
> my code has to be confused too". Or do your &s and &&s behave
> differently from ours?
Well, the code looks weird. However, it doesn't behave the same when
CONFIG_IDEDMA_IVB is enabled or not. If it is not, normal case, it's
just:
(drive->id->hw_config & 0x6000)
If CONFIG_IDEDMA_IVB is enabled, it boils down to:
(drive->id->hw_config & 0x4000)
because the second bit test includes the earlier test already only
loosening it. Because of that, it's superfluous. And the code relies on
the compiler to optimize it out.
If written like:
#ifndef CONFIG_IDEDMA_IVB
#define IDE_UDMA_MASK 0x4000
#else
#define IDE_UDMA_MASK 0x6000
#endif /* CONFIG_IDEDMA_IVB */
byte eighty_ninty_three (ide_drive_t *drive)
{
return HWIF(drive)->udma_four &&
(drive->id->hw_config & IDE_UDMA_MASK);
}
it'd be probably somewhat clearer.
--
Vojtech Pavlik
SuSE Labs
next prev parent reply other threads:[~2001-02-20 18:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.21.0102201705280.11260-100000@alloc>
2001-02-20 17:45 ` [IDE] meaningless #ifndef? Hugh Dickins
2001-02-20 18:20 ` Vojtech Pavlik [this message]
2001-02-20 19:08 ` Hugh Dickins
2001-02-19 21:57 Pozsar Balazs
2001-02-19 22:31 ` Andre Hedrick
2001-02-19 23:31 ` Bill Wendling
2001-02-19 23:34 ` Andre Hedrick
2001-02-20 4:45 ` Tom Leete
2001-02-20 5:10 ` Tom Leete
2001-02-20 9:47 ` Andrzej Krzysztofowicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010220192056.A6846@suse.cz \
--to=vojtech@suse.cz \
--cc=andre@linux-ide.org \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pozsy@sch.bme.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox