include/linux/range.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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@twin.jikos.cz/ [1]
Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
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@intel.com>
On Thu, Oct 10, 2024 at 10:24:42AM -0500, Ira Weiny wrote: > 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@twin.jikos.cz/ [1] > Suggested-by: David Sterba <dsterba@suse.cz> You can drop the above line. > Signed-off-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: David Sterba <dsterba@suse.com>
David Sterba wrote: > On Thu, Oct 10, 2024 at 10:24:42AM -0500, Ira Weiny wrote: > > 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@twin.jikos.cz/ [1] > > Suggested-by: David Sterba <dsterba@suse.cz> > > You can drop the above line. Done. > > > Signed-off-by: Ira Weiny <ira.weiny@intel.com> > > Reviewed-by: David Sterba <dsterba@suse.com> Queued in the cxl-next tree. Thanks! Ira
Ira Weiny wrote: > 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@twin.jikos.cz/ [1] > Suggested-by: David Sterba <dsterba@suse.cz> > Signed-off-by: Ira Weiny <ira.weiny@intel.com> LGTM Reviewed-by: Dan Williams <dan.j.williams@intel.com>
© 2016 - 2025 Red Hat, Inc.