Commit afb34781 authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Mauro Carvalho Chehab

media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros

When building with Clang + -Wtautological-constant-compare, several of
the ivtv and cx18 drivers warn along the lines of:

 drivers/media/pci/cx18/cx18-driver.c:1005:21: warning: converting the
 result of '<<' to a boolean always evaluates to true
 [-Wtautological-constant-compare]
                         cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
                                         ^
 drivers/media/pci/cx18/cx18-cards.h:18:37: note: expanded from macro
 'CX18_HW_GPIO_RESET_CTRL'
 #define CX18_HW_GPIO_RESET_CTRL         (1 << 6)
                                           ^
 1 warning generated.

This warning happens because the shift operation is implicitly converted
to a boolean in v4l2_device_mask_call_all before being negated. This can
be solved by just comparing the mask result to 0 explicitly so that
there is no boolean conversion. The ultimate goal is to enable
-Wtautological-compare globally because there are several subwarnings
that would be helpful to have.

For visual consistency and avoidance of these warnings in the future,
all of the implicitly boolean conversions in the v4l2_device macros
are converted to explicit ones as well.

Link: https://github.com/ClangBuiltLinux/linux/issues/752Reviewed-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 8c2d66b0
...@@ -371,7 +371,7 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev) ...@@ -371,7 +371,7 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
struct v4l2_subdev *__sd; \ struct v4l2_subdev *__sd; \
\ \
__v4l2_device_call_subdevs_p(v4l2_dev, __sd, \ __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
!(grpid) || __sd->grp_id == (grpid), o, f , \ (grpid) == 0 || __sd->grp_id == (grpid), o, f , \
##args); \ ##args); \
} while (0) } while (0)
...@@ -403,7 +403,7 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev) ...@@ -403,7 +403,7 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
({ \ ({ \
struct v4l2_subdev *__sd; \ struct v4l2_subdev *__sd; \
__v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \ __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
!(grpid) || __sd->grp_id == (grpid), o, f , \ (grpid) == 0 || __sd->grp_id == (grpid), o, f , \
##args); \ ##args); \
}) })
...@@ -431,8 +431,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev) ...@@ -431,8 +431,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
struct v4l2_subdev *__sd; \ struct v4l2_subdev *__sd; \
\ \
__v4l2_device_call_subdevs_p(v4l2_dev, __sd, \ __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
!(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \ (grpmsk) == 0 || (__sd->grp_id & (grpmsk)), o, \
##args); \ f , ##args); \
} while (0) } while (0)
/** /**
...@@ -462,8 +462,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev) ...@@ -462,8 +462,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
({ \ ({ \
struct v4l2_subdev *__sd; \ struct v4l2_subdev *__sd; \
__v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \ __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
!(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \ (grpmsk) == 0 || (__sd->grp_id & (grpmsk)), o, \
##args); \ f , ##args); \
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment