mm: use ARRAY_END() instead of open-coding it

There aren't any bugs in this code; it's purely cosmetic.

By using ARRAY_END(), we prevent future issues, in case the code is
modified; it has less moving parts.  Also, it should be more readable (and
perhaps more importantly, greppable), as there are several ways of writing
an expression that gets the end of an array, which are unified by this API
name.

Link: https://lkml.kernel.org/r/2335917d123891fec074ab1b3acfb517cf14b5a7.1765449750.git.alx@kernel.org
Signed-off-by: Alejandro Colomar <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Christopher Bazley <[email protected]>
Cc: Dmitriy Vyukov <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Cc: Marco Elver <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
Alejandro Colomar
2026-01-20 19:44:20 -08:00
committed by Andrew Morton
parent a9e5620c9a
commit 61e9210e23
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -510,7 +510,7 @@ static void mem_pool_free(struct kmemleak_object *object)
{
unsigned long flags;
if (object < mem_pool || object >= mem_pool + ARRAY_SIZE(mem_pool)) {
if (object < mem_pool || object >= ARRAY_END(mem_pool)) {
kmem_cache_free(object_cache, object);
return;
}
+2 -2
View File
@@ -1794,7 +1794,7 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
mem_cgroup_flush_stats(memcg);
for (stat = stats; stat < stats + ARRAY_SIZE(stats); stat++) {
for (stat = stats; stat < ARRAY_END(stats); stat++) {
seq_printf(m, "%s=%lu", stat->name,
mem_cgroup_nr_lru_pages(memcg, stat->lru_mask,
false));
@@ -1805,7 +1805,7 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
seq_putc(m, '\n');
}
for (stat = stats; stat < stats + ARRAY_SIZE(stats); stat++) {
for (stat = stats; stat < ARRAY_END(stats); stat++) {
seq_printf(m, "hierarchical_%s=%lu", stat->name,
mem_cgroup_nr_lru_pages(memcg, stat->lru_mask,