[PATCH 3/4] iommupt: Make PT_SUPPORTED_FEATURE() return 0 or 1

From: Vineet Gupta

Date: Wed Nov 04 2026 - 11:12:30 EST


GCC 17 adds -Wconstant-logical-operand to -Wall. It warns when an operand
of && or || folds to a constant other than 0 or 1. PT_SUPPORTED_FEATURE()
returns the raw feature bit, and the fvalog2_*() helpers use it as an &&
operand. The build fails with CONFIG_WERROR=y:

drivers/iommu/generic_pt/fmt/../pt_defs.h:255:51: error: use of logical '&&' with constant operand '2' [-Werror=constant-logical-operand]

clang has the same warning, but it checks only a constant right operand.

Compare the masked value against 0. All users test the result as a truth
value, so the behaviour does not change.

Signed-off-by: Vineet Gupta <vineet.gupta@xxxxxxxxx>
---
drivers/iommu/generic_pt/pt_defs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/generic_pt/pt_defs.h b/drivers/iommu/generic_pt/pt_defs.h
index 707b3b0282fa..51a9c1c5fcc9 100644
--- a/drivers/iommu/generic_pt/pt_defs.h
+++ b/drivers/iommu/generic_pt/pt_defs.h
@@ -200,7 +200,7 @@ static inline bool pt_table_install32(struct pt_state *pts, u32 table_entry)
return ret;
}

-#define PT_SUPPORTED_FEATURE(feature_nr) (PT_SUPPORTED_FEATURES & BIT(feature_nr))
+#define PT_SUPPORTED_FEATURE(feature_nr) ((PT_SUPPORTED_FEATURES & BIT(feature_nr)) != 0)

static __always_inline bool pt_feature(const struct pt_common *common,
unsigned int feature_nr)
--
2.53.0-Meta