[PATCH] rbd: cast snap_count to size_t to avoid tautological comparison warning

From: Rosen Penev

Date: Thu May 28 2026 - 16:23:48 EST


snap_count is u32 but the comparison is against a SIZE_MAX-derived value
(~2^61 on 64-bit), which clang flags as always false with
-Wtautological-constant-out-of-range-compare. Cast to size_t so the
comparison is done in the correct width.

Assisted-by: Opencode:Big-pickle
Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/block/rbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 94709466ad19..b4ba51db9a28 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6079,7 +6079,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev,
* make sure the computed size of the snapshot context we
* allocate is representable in a size_t.
*/
- if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
+ if ((size_t)snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
/ sizeof (u64)) {
ret = -EINVAL;
goto out;
--
2.54.0