Re: [PATCH] floppy: fix harmless clang build warning
From: Keith Busch
Date: Wed Mar 13 2019 - 18:12:18 EST
On Wed, Mar 13, 2019 at 10:01:43PM +0000, Elliott, Robert (Persistent Memory) wrote:
> > @@ -3899,7 +3899,7 @@ static void __init config_types(void)
> > if (!UDP->cmos)
> > UDP->cmos = FLOPPY0_TYPE;
> > drive = 1;
> > - if (!UDP->cmos && FLOPPY1_TYPE)
> > + if (!UDP->cmos)
> > UDP->cmos = FLOPPY1_TYPE;
> >
> > /* FIXME: additional physical CMOS drive detection should go here */
> > --
> > 2.20.0
>
> On x86 it expands to a hardware read, so this would change the control flow.
>
> #define FLOPPY1_TYPE \
> ({ \
> unsigned long flags; \
> unsigned char val; \
> spin_lock_irqsave(&rtc_lock, flags); \
> val = CMOS_READ(0x10) & 15; \
> spin_unlock_irqrestore(&rtc_lock, flags); \
> val; \
> })
The end result is still the same, though. It just doesn't read the
hardware twice when FLOPPY1_TYPE is non-zero.