patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/cdx: Add parentheses between bitwise AND expression and logical NOT
@ 2023-10-02 17:53 Nathan Chancellor
  2023-10-02 17:57 ` Nick Desaulniers
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nathan Chancellor @ 2023-10-02 17:53 UTC (permalink / raw)
  To: nipun.gupta, nikhil.agarwal, alex.williamson
  Cc: ndesaulniers, trix, shubham.rohila, kvm, llvm, patches,
	Nathan Chancellor

When building with clang, there is a warning (or error with
CONFIG_WERROR=y) due to a bitwise AND and logical NOT in
vfio_cdx_bm_ctrl():

  drivers/vfio/cdx/main.c:77:6: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
     77 |         if (!vdev->flags & BME_SUPPORT)
        |             ^            ~
  drivers/vfio/cdx/main.c:77:6: note: add parentheses after the '!' to evaluate the bitwise operator first
     77 |         if (!vdev->flags & BME_SUPPORT)
        |             ^
        |              (                        )
  drivers/vfio/cdx/main.c:77:6: note: add parentheses around left hand side expression to silence this warning
     77 |         if (!vdev->flags & BME_SUPPORT)
        |             ^
        |             (           )
  1 error generated.

Add the parentheses as suggested in the first note, which is clearly
what was intended here.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1939
Fixes: 8a97ab9b8b31 ("vfio-cdx: add bus mastering device feature support")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/vfio/cdx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/cdx/main.c b/drivers/vfio/cdx/main.c
index a437630be354..a63744302b5e 100644
--- a/drivers/vfio/cdx/main.c
+++ b/drivers/vfio/cdx/main.c
@@ -74,7 +74,7 @@ static int vfio_cdx_bm_ctrl(struct vfio_device *core_vdev, u32 flags,
 	struct vfio_device_feature_bus_master ops;
 	int ret;
 
-	if (!vdev->flags & BME_SUPPORT)
+	if (!(vdev->flags & BME_SUPPORT))
 		return -ENOTTY;
 
 	ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_SET,

---
base-commit: fcb2f2ed4a80cfe383d87da75caba958516507e9
change-id: 20231002-vfio-cdx-logical-not-parentheses-aca8fbd6b278

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-04  6:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-02 17:53 [PATCH] vfio/cdx: Add parentheses between bitwise AND expression and logical NOT Nathan Chancellor
2023-10-02 17:57 ` Nick Desaulniers
2023-10-03  4:17 ` Agarwal, Nikhil
2023-10-03  7:40 ` Philippe Mathieu-Daudé
2023-10-03 15:27   ` Nathan Chancellor
2023-10-03 17:20     ` Alex Williamson
2023-10-04  6:48       ` Philippe Mathieu-Daudé
2023-10-03 18:01 ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).