Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame^] | 1 | From 74979dd6327bbaa96ecb8525f8ea6025715d5ba7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Xiongwei Song <sxwjean@gmail.com> |
| 3 | Date: Fri, 14 Jan 2022 14:07:24 -0800 |
| 4 | Subject: [PATCH] mm: page_alloc: fix building error on -Werror=array-compare |
| 5 | |
| 6 | Arthur Marsh reported we would hit the error below when building kernel |
| 7 | with gcc-12: |
| 8 | |
| 9 | CC mm/page_alloc.o |
| 10 | mm/page_alloc.c: In function `mem_init_print_info': |
| 11 | mm/page_alloc.c:8173:27: error: comparison between two arrays [-Werror=array-compare] |
| 12 | 8173 | if (start <= pos && pos < end && size > adj) \ |
| 13 | | |
| 14 | |
| 15 | In C++20, the comparision between arrays should be warned. |
| 16 | |
| 17 | Link: https://lkml.kernel.org/r/20211125130928.32465-1-sxwjean@me.com |
| 18 | Signed-off-by: Xiongwei Song <sxwjean@gmail.com> |
| 19 | Reported-by: Arthur Marsh <arthur.marsh@internode.on.net> |
| 20 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| 21 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> |
| 22 | |
| 23 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ca831f29f8f25c97182e726429b38c0802200c8f] |
| 24 | Signed-off-by: Davidson K <davidson.kumaresan@arm.com> |
| 25 | Change-Id: I11931013f1fd42f0f2a75375cdfb129cb3a9d5aa |
| 26 | --- |
| 27 | mm/page_alloc.c | 2 +- |
| 28 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 29 | |
| 30 | diff --git a/mm/page_alloc.c b/mm/page_alloc.c |
| 31 | index 185fbddecc83..3affeeb194d4 100644 |
| 32 | --- a/mm/page_alloc.c |
| 33 | +++ b/mm/page_alloc.c |
| 34 | @@ -8282,7 +8282,7 @@ void __init mem_init_print_info(void) |
| 35 | */ |
| 36 | #define adj_init_size(start, end, size, pos, adj) \ |
| 37 | do { \ |
| 38 | - if (start <= pos && pos < end && size > adj) \ |
| 39 | + if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \ |
| 40 | size -= adj; \ |
| 41 | } while (0) |
| 42 | |
| 43 | -- |
| 44 | 2.34.1 |
| 45 | |