* [PATCH] [RESEND] floppy: fix harmless clang build warning
@ 2019-06-19 13:19 Arnd Bergmann
2019-06-20 7:36 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2019-06-19 13:19 UTC (permalink / raw)
To: Jiri Kosina, Jens Axboe
Cc: Arnd Bergmann, Robert Elliott, Keith Busch, Hannes Reinecke,
Omar Sandoval, Sakari Ailus, Andy Whitcroft, 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.
On x86, this will no longer read a hardware register, as the
FLOPPY1_TYPE macro is not expanded if UDP->cmos is already
zero, but the result is the same.
Cc: Robert Elliott <elliott@hpe.com>
Cc: Keith Busch <kbusch@kernel.org>
Link: https://patchwork.kernel.org/patch/10851841/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
The original patch did not get merged since there was some
discussion (see link), but as far as I can tell, the outcome
was that it's harmless so I just summarized the findings
above. The patch is unchanged from March.
---
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 9fb9b312ab6b..b933a7eea52b 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3900,7 +3900,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 [flat|nested] 2+ messages in thread* Re: [PATCH] [RESEND] floppy: fix harmless clang build warning
2019-06-19 13:19 [PATCH] [RESEND] floppy: fix harmless clang build warning Arnd Bergmann
@ 2019-06-20 7:36 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2019-06-20 7:36 UTC (permalink / raw)
To: Arnd Bergmann, Jiri Kosina
Cc: Robert Elliott, Keith Busch, Hannes Reinecke, Omar Sandoval,
Sakari Ailus, Andy Whitcroft, linux-block, linux-kernel
On 6/19/19 7:19 AM, Arnd Bergmann wrote:
> 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.
>
> On x86, this will no longer read a hardware register, as the
> FLOPPY1_TYPE macro is not expanded if UDP->cmos is already
> zero, but the result is the same.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-20 7:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 13:19 [PATCH] [RESEND] floppy: fix harmless clang build warning Arnd Bergmann
2019-06-20 7:36 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®