Skip to contentSkip to conversation

kernel/range: Const-ify range_contains parameters

PATCH In review Ira Weiny 3 participants 4 messages Oct 10, 2024 – Oct 11, 2024 Btrfs file system

lore
Share & tools
lore

Ira Weiny

author
#0 lore raw

PATCH 1/1 kernel/range: Const-ify range_contains parameters

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

Make range parameters const

---
 include/linux/range.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/range.h +2 -1
index 6ad0b73cb7ad..7dc5e835e079 100644
@@ -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,

Signature · 1 line
Ira Weiny <[email protected]>
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ira Weiny
Quoted 7 lines · Ira Weiny

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

Make range parameters const

You can drop the above line.

Quoted 1 line
author Applied
#3 lore raw
Quoted 10 lines · David Sterba
Quoted 7 lines · Ira Weiny

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

Make range parameters const

You can drop the above line.

Done.

Quoted 4 lines
Quoted 2 lines

Queued in the cxl-next tree.

Thanks!
Ira