Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1687192

[PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning
Date 2017-07-14 11:40 +0200
Message-ID <u35eN-1tG-9@gated-at.bofh.it> (permalink)
References <u3558-1oP-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When we pass the result of a multiplication as the timeout, we
can get a warning:

drivers/mmc/host/bcm2835.c:596:149: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/mfd/arizona-core.c:247:195: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

This is easy to avoid by comparing the timeout to zero instead,
making it a boolean expression.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/iopoll.h | 6 ++++--
 include/linux/regmap.h | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index d29e1e21bf3f..7a17ba02253b 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -48,7 +48,8 @@
 		(val) = op(addr); \
 		if (cond) \
 			break; \
-		if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
+		if ((timeout_us) > 0 && \
+		    ktime_compare(ktime_get(), timeout) > 0) { \
 			(val) = op(addr); \
 			break; \
 		} \
@@ -82,7 +83,8 @@
 		(val) = op(addr); \
 		if (cond) \
 			break; \
-		if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
+		if ((timeout_us) > 0 && \
+		    ktime_compare(ktime_get(), timeout) > 0) { \
 			(val) = op(addr); \
 			break; \
 		} \
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 1474ab0a3922..0889dbf37161 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -129,7 +129,7 @@ struct reg_sequence {
 			break; \
 		if (cond) \
 			break; \
-		if ((timeout_us) && \
+		if ((timeout_us) > 0 && \
 		    ktime_compare(ktime_get(), __timeout) > 0) { \
 			__ret = regmap_read((map), (addr), &(val)); \
 			break; \
-- 
2.9.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/14] gcc-7 warnings Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:30 +0200
  [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:30 +0200
    Re: [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning Joe Perches <joe@perches.com> - 2017-07-14 12:10 +0200
      Re: [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 12:40 +0200
        Re: [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning Kevin Easton <kevin@guarana.org> - 2017-07-15 06:30 +0200
  [PATCH 04/14] x86: math-emu: avoid -Wint-in-bool-context warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:30 +0200
  [PATCH 07/14] proc/kcore: hide a harmless warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:30 +0200
    Re: [PATCH 07/14] proc/kcore: hide a harmless warning Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-07-14 14:30 +0200
  [PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
    Re: [PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning Joe Perches <joe@perches.com> - 2017-07-14 12:00 +0200
      Re: [PATCH 13/14] iopoll: avoid -Wint-in-bool-context warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 12:30 +0200
  [PATCH 09/14] SFI: fix tautological-compare warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
  [PATCH 11/14] IB/uverbs: fix gcc-7 type warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
    Re: [PATCH 11/14] IB/uverbs: fix gcc-7 type warning Leon Romanovsky <leon@kernel.org> - 2017-07-14 11:50 +0200
  [PATCH 10/14] staging:iio:resolver:ad2s1210 fix negative IIO_ANGL_VEL read Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
    Re: [PATCH 10/14] staging:iio:resolver:ad2s1210 fix negative  IIO_ANGL_VEL read Jonathan Cameron <jic23@kernel.org> - 2017-07-15 13:50 +0200
  [PATCH 12/14] drm/nouveau/clk: fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
  [PATCH 06/14] acpi: thermal: fix gcc-6/ccache warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
  [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:40 +0200
    Re: [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-14 21:30 +0200
      Re: [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann <arnd@arndb.de> - 2017-07-14 22:20 +0200
        Re: [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context  warning Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-07-14 23:50 +0200
  [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result interpreted as bool Arnd Bergmann <arnd@arndb.de> - 2017-07-14 11:50 +0200
    Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-14 14:10 +0200
      Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Arnd Bergmann <arnd@arndb.de> - 2017-07-14 14:30 +0200
        Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-14 15:00 +0200
          Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-14 15:20 +0200
            Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Arnd Bergmann <arnd@arndb.de> - 2017-07-14 21:40 +0200
    Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-14 14:50 +0200
    Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Hans Verkuil <hverkuil@xs4all.nl> - 2017-07-17 15:50 +0200
      Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Arnd Bergmann <arnd@arndb.de> - 2017-07-17 16:30 +0200
        Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Hans Verkuil <hverkuil@xs4all.nl> - 2017-07-17 16:40 +0200
          Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Arnd Bergmann <arnd@arndb.de> - 2017-07-17 23:30 +0200
        Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-17 16:40 +0200
        Re: [PATCH 14/14] [media] fix warning on v4l2_subdev_call() result  interpreted as bool Hans Verkuil <hverkuil@xs4all.nl> - 2017-07-17 16:40 +0200
  Re: [PATCH 00/14] gcc-7 warnings Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-07-14 12:30 +0200

csiph-web