LKML Archive on
 help / color / Atom feed
From: Nathan Chancellor <>
To: Mauro Carvalho Chehab <>
	Nathan Chancellor <>
Subject: [PATCH] media: v4l2-device.h: Explicitly compare grpmask to zero in v4l2_device_mask_call_all
Date: Thu, 24 Oct 2019 13:12:41 -0700
Message-ID: <> (raw)

When building with Clang + -Wtautological-constant-compare, several of
the ivtv 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
                         cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
 drivers/media/pci/cx18/cx18-cards.h:18:37: note: expanded from macro
 #define CX18_HW_GPIO_RESET_CTRL         (1 << 6)
 1 warning generated.

This is 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 explicity so that there is no
boolean conversion.

Signed-off-by: Nathan Chancellor <>

I am aware that there is suddenly a style mismatch (some macros using
!(grpmask) and this one using (grpmask) == 0) but I chose to display the
minimal fix. If you want me to update all the macros to use this style,
I'd be happy to in a followup patch.

There are 19 of these warnings in the drivers/media/pci folder, which
can be seen here:

This is the simplest fix but if you all prefer an alternative one, I
would be happy to see/review/test it. The ultimate goal is to get
-Wtautological-compare enabled because there are several subwarnings
that would be helpful to have and right now they are all disabled:

 include/media/v4l2-device.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index e0b8f2602670..8564b3227887 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -431,8 +431,8 @@ static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
 		struct v4l2_subdev *__sd;				\
 		__v4l2_device_call_subdevs_p(v4l2_dev, __sd,		\
-			!(grpmsk) || (__sd->grp_id & (grpmsk)), o, f ,	\
-			##args);					\
+			(grpmsk) == 0 || (__sd->grp_id & (grpmsk)), o,	\
+			f , ##args);					\
 	} while (0)

             reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 20:12 Nathan Chancellor [this message]
2019-11-04 19:07 ` Nick Desaulniers
2019-11-05  4:59 ` [PATCH v2] " Nathan Chancellor
2019-12-06 21:59   ` Nick Desaulniers
2019-12-07 10:41   ` Ezequiel Garcia
2019-12-08 21:11   ` [PATCH v3] media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git
	git clone --mirror lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone