Skip to content

Commit 61e9210

Browse files
alejandro-colomarakpm00
authored andcommitted
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]>
1 parent a9e5620 commit 61e9210

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

mm/kmemleak.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ static void mem_pool_free(struct kmemleak_object *object)
510510
{
511511
unsigned long flags;
512512

513-
if (object < mem_pool || object >= mem_pool + ARRAY_SIZE(mem_pool)) {
513+
if (object < mem_pool || object >= ARRAY_END(mem_pool)) {
514514
kmem_cache_free(object_cache, object);
515515
return;
516516
}

mm/memcontrol-v1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
17941794

17951795
mem_cgroup_flush_stats(memcg);
17961796

1797-
for (stat = stats; stat < stats + ARRAY_SIZE(stats); stat++) {
1797+
for (stat = stats; stat < ARRAY_END(stats); stat++) {
17981798
seq_printf(m, "%s=%lu", stat->name,
17991799
mem_cgroup_nr_lru_pages(memcg, stat->lru_mask,
18001800
false));
@@ -1805,7 +1805,7 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
18051805
seq_putc(m, '\n');
18061806
}
18071807

1808-
for (stat = stats; stat < stats + ARRAY_SIZE(stats); stat++) {
1808+
for (stat = stats; stat < ARRAY_END(stats); stat++) {
18091809

18101810
seq_printf(m, "hierarchical_%s=%lu", stat->name,
18111811
mem_cgroup_nr_lru_pages(memcg, stat->lru_mask,

0 commit comments

Comments
 (0)