* [PATCH] floppy: fix harmless clang build warning
@ 2019-03-13 21:11 Arnd Bergmann
2019-03-13 22:01 ` Elliott, Robert (Persistent Memory)
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-13 21:11 UTC (permalink / raw)
To: Jiri Kosina, Jens Axboe
Cc: Arnd Bergmann, Omar Sandoval, Hannes Reinecke, linux-block, linux-kernel
clang warns about unusual code in floppy.c that looks like it
was intended to be a bit mask operation, checking for a specific
bit in the UDP->cmos variable (FLOPPY1_TYPE expands to '4' on
ARM):
drivers/block/floppy.c:3902:17: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
if (!UDP->cmos && FLOPPY1_TYPE)
^ ~~~~~~~~~~~~
drivers/block/floppy.c:3902:17: note: use '&' for a bitwise operation
if (!UDP->cmos && FLOPPY1_TYPE)
The check here is redundant anyway, if FLOPPY1_TYPE is zero, then
assigning it to a zero UDP->cmos field does not change anything,
so removing the extra check here has no effect other than shutting
up the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/block/floppy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 95f608d1a098..56815446ed85 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] floppy: fix harmless clang build warning
2019-03-13 21:11 [PATCH] floppy: fix harmless clang build warning Arnd Bergmann
@ 2019-03-13 22:01 ` Elliott, Robert (Persistent Memory)
2019-03-13 22:12 ` Keith Busch
0 siblings, 1 reply; 3+ messages in thread
From: Elliott, Robert (Persistent Memory) @ 2019-03-13 22:01 UTC (permalink / raw)
To: Arnd Bergmann, Jiri Kosina, Jens Axboe
Cc: Omar Sandoval, Hannes Reinecke, linux-block, linux-kernel
> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Arnd
> Bergmann
> Sent: Wednesday, March 13, 2019 4:11 PM
> To: Jiri Kosina <jikos@kernel.org>; Jens Axboe <axboe@kernel.dk>
> Cc: Arnd Bergmann <arnd@arndb.de>; Omar Sandoval <osandov@fb.com>; Hannes Reinecke <hare@suse.de>;
> linux-block@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] floppy: fix harmless clang build warning
>
> clang warns about unusual code in floppy.c that looks like it
> was intended to be a bit mask operation, checking for a specific
> bit in the UDP->cmos variable (FLOPPY1_TYPE expands to '4' on
> ARM):
>
> drivers/block/floppy.c:3902:17: error: use of logical '&&' with constant operand [-Werror,-Wconstant-
> logical-operand]
> if (!UDP->cmos && FLOPPY1_TYPE)
> ^ ~~~~~~~~~~~~
> drivers/block/floppy.c:3902:17: note: use '&' for a bitwise operation
> if (!UDP->cmos && FLOPPY1_TYPE)
>
> The check here is redundant anyway, if FLOPPY1_TYPE is zero, then
> assigning it to a zero UDP->cmos field does not change anything,
> so removing the extra check here has no effect other than shutting
> up the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/block/floppy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 95f608d1a098..56815446ed85 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -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; \
})
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] floppy: fix harmless clang build warning
2019-03-13 22:01 ` Elliott, Robert (Persistent Memory)
@ 2019-03-13 22:12 ` Keith Busch
0 siblings, 0 replies; 3+ messages in thread
From: Keith Busch @ 2019-03-13 22:12 UTC (permalink / raw)
To: Elliott, Robert (Persistent Memory)
Cc: Arnd Bergmann, Jiri Kosina, Jens Axboe, Omar Sandoval,
Hannes Reinecke, linux-block, linux-kernel
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-13 22:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 21:11 [PATCH] floppy: fix harmless clang build warning Arnd Bergmann
2019-03-13 22:01 ` Elliott, Robert (Persistent Memory)
2019-03-13 22:12 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).