linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* page_alloc.c comparison of arrays warning in function mem_init_print_info
@ 2021-11-19 11:00 Arthur Marsh
  2021-11-19 14:47 ` Song Xiongwei
  0 siblings, 1 reply; 3+ messages in thread
From: Arthur Marsh @ 2021-11-19 11:00 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm

Hi, when seeing what build issues there were in building the current Linux git head kernel using gcc-12, I came across:

CC      mm/page_alloc.o
mm/page_alloc.c: In function ‘mem_init_print_info’:
mm/page_alloc.c:8173:27: error: comparison between two arrays [-Werror=array-compare]
 8173 |                 if (start <= pos && pos < end && size > adj) \
      |                           ^~

Are there any patches that address this? 

Regards, 

Arthur. 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: page_alloc.c comparison of arrays warning in function mem_init_print_info
  2021-11-19 11:00 page_alloc.c comparison of arrays warning in function mem_init_print_info Arthur Marsh
@ 2021-11-19 14:47 ` Song Xiongwei
  2021-11-20 10:05   ` Arthur Marsh
  0 siblings, 1 reply; 3+ messages in thread
From: Song Xiongwei @ 2021-11-19 14:47 UTC (permalink / raw)
  To: Arthur Marsh, akpm; +Cc: linux-mm

Hi,

On 2021/11/19 下午7:00, Arthur Marsh wrote:
> Hi, when seeing what build issues there were in building the current Linux git head kernel using gcc-12, I came across:
>
> CC      mm/page_alloc.o
> mm/page_alloc.c: In function ‘mem_init_print_info’:
> mm/page_alloc.c:8173:27: error: comparison between two arrays [-Werror=array-compare]
>   8173 |                 if (start <= pos && pos < end && size > adj) \
>        |                           ^~
>
> Are there any patches that address this?

Please give a try with the patch below:

 From ca5ce459a256a4847fff96778e78ce1711e9e74b Mon Sep 17 00:00:00 2001
From: Xiongwei Song <sxwjean@gmail.com>
Date: Fri, 19 Nov 2021 22:19:59 +0800
Subject: [PATCH] mm: page_alloc: Fix building error on 
-Werror=array-compare

CC      mm/page_alloc.o
mm/page_alloc.c: In function ‘mem_init_print_info’:
mm/page_alloc.c:8173:27: error: comparison between two arrays 
[-Werror=array-compare]
  8173 |                 if (start <= pos && pos < end && size > adj) \
       |

Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
---
  mm/page_alloc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c5952749ad40..8f304c3d0e19 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -8170,7 +8170,7 @@ void __init mem_init_print_info(void)
       */
  #define adj_init_size(start, end, size, pos, adj) \
      do { \
-        if (start <= pos && pos < end && size > adj) \
+        if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \
              size -= adj; \
      } while (0)

-- 
Regards,

Xiongwei

>
> Regards,
>
> Arthur.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: page_alloc.c comparison of arrays warning in function mem_init_print_info
  2021-11-19 14:47 ` Song Xiongwei
@ 2021-11-20 10:05   ` Arthur Marsh
  0 siblings, 0 replies; 3+ messages in thread
From: Arthur Marsh @ 2021-11-20 10:05 UTC (permalink / raw)
  To: Song Xiongwei, akpm; +Cc: linux-mm

Thanks, applied the patch and built the kernel with gcc-12 and successfully booted the new kernel.

Regards,

Arthur. 

On 20 November 2021 1:17:25 am ACDT, Song Xiongwei <sxwjean@me.com> wrote:
>Hi,
>
>On 2021/11/19 下午7:00, Arthur Marsh wrote:
>> Hi, when seeing what build issues there were in building the current Linux git head kernel using gcc-12, I came across:
>>
>> CC      mm/page_alloc.o
>> mm/page_alloc.c: In function ‘mem_init_print_info’:
>> mm/page_alloc.c:8173:27: error: comparison between two arrays [-Werror=array-compare]
>>   8173 |                 if (start <= pos && pos < end && size > adj) \
>>        |                           ^~
>>
>> Are there any patches that address this?
>
>Please give a try with the patch below:
>
> From ca5ce459a256a4847fff96778e78ce1711e9e74b Mon Sep 17 00:00:00 2001
>From: Xiongwei Song <sxwjean@gmail.com>
>Date: Fri, 19 Nov 2021 22:19:59 +0800
>Subject: [PATCH] mm: page_alloc: Fix building error on 
>-Werror=array-compare
>
>CC      mm/page_alloc.o
>mm/page_alloc.c: In function ‘mem_init_print_info’:
>mm/page_alloc.c:8173:27: error: comparison between two arrays 
>[-Werror=array-compare]
>  8173 |                 if (start <= pos && pos < end && size > adj) \
>       |
>
>Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
>Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
>---
>  mm/page_alloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>index c5952749ad40..8f304c3d0e19 100644
>--- a/mm/page_alloc.c
>+++ b/mm/page_alloc.c
>@@ -8170,7 +8170,7 @@ void __init mem_init_print_info(void)
>       */
>  #define adj_init_size(start, end, size, pos, adj) \
>      do { \
>-        if (start <= pos && pos < end && size > adj) \
>+        if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \
>              size -= adj; \
>      } while (0)
>

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-20 10:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 11:00 page_alloc.c comparison of arrays warning in function mem_init_print_info Arthur Marsh
2021-11-19 14:47 ` Song Xiongwei
2021-11-20 10:05   ` Arthur Marsh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox