Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 20 Feb 2001 14:09:08 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 20 Feb 2001 14:08:58 -0500 Received: from [62.172.234.2] ([62.172.234.2]:53326 "EHLO localhost.localdomain") by vger.kernel.org with ESMTP id ; Tue, 20 Feb 2001 14:08:42 -0500 Date: Tue, 20 Feb 2001 19:08:37 +0000 (GMT) From: Hugh Dickins To: Vojtech Pavlik cc: Andre Hedrick , Pozsar Balazs , linux-kernel Subject: Re: [IDE] meaningless #ifndef? In-Reply-To: <20010220192056.A6846@suse.cz> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Feb 2001, Vojtech Pavlik wrote: > On Tue, Feb 20, 2001 at 05:45:52PM +0000, Hugh Dickins wrote: > > > > 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); > > > > } > > 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. Thank you for re-explaining this to me. Yes, you are right, I was wrong, I now admit my &s and &&s behave like yours, and I apologize to Andre! > 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. That would certainly have helped us! Hugh - 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/