[PATCH] kernel/range: Const-ify range_contains parameters

From: Ira Weiny
Date: Thu Oct 10 2024 - 11:25:43 EST


range_contains() does not modify the range values. David suggested it
is safer to keep those parameters as const.[1]

Make range parameters const

Link: https://lore.kernel.org/all/20241008161032.GB1609@xxxxxxxxxxxxx/ [1]
Suggested-by: David Sterba <dsterba@xxxxxxx>
Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
---
include/linux/range.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/range.h b/include/linux/range.h
index 6ad0b73cb7ad..7dc5e835e079 100644
--- a/include/linux/range.h
+++ b/include/linux/range.h
@@ -13,7 +13,8 @@ static inline u64 range_len(const struct range *range)
return range->end - range->start + 1;
}

-static inline bool range_contains(struct range *r1, struct range *r2)
+static inline bool range_contains(const struct range *r1,
+ const struct range *r2)
{
return r1->start <= r2->start && r1->end >= r2->end;
}

---
base-commit: 27cc6fdf720183dce1dbd293483ec5a9cb6b595e
change-id: 20241009-const-range-35475803a824

Best regards,
--
Ira Weiny <ira.weiny@xxxxxxxxx>