From patchwork Thu Nov 25 13:09:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 12639059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FF1DC433EF for ; Thu, 25 Nov 2021 13:10:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 845986B0074; Thu, 25 Nov 2021 08:10:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F5756B0075; Thu, 25 Nov 2021 08:10:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E5B76B007B; Thu, 25 Nov 2021 08:10:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 5CB406B0074 for ; Thu, 25 Nov 2021 08:10:12 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1231318507855 for ; Thu, 25 Nov 2021 13:10:02 +0000 (UTC) X-FDA: 78847485444.26.A4979E0 Received: from pv50p00im-zteg10021301.me.com (pv50p00im-zteg10021301.me.com [17.58.6.46]) by imf26.hostedemail.com (Postfix) with ESMTP id AF08720019D6 for ; Thu, 25 Nov 2021 13:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1637845800; bh=+ArmKywOdE09QNfbBo1DffDIX/nRSHFgP3KVGEK0QRk=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=fWEJ8S15hPUNtju4XKMDIzehtfNEj9cnibuTxkiwHhqKxQHDMcUzGXYJ3uSNoqzhY Lnq0KXZtMdgMHe+d3LAMY6dEI1nphQg18Mced5dDu7hyOFKULaR26lZ1fJwN4TnU/U FvGTWDp+bxvb4JdVzeDOOTifkjkRpdWaCYphB1B1DnvHkkjJjlIfOvxbNi4R8kMyKO NNumwk2ocWLlJtr4u3dPC5ubAKK8E6Wuscut/CkSffBP0oJx9rsKOB6Tt05LBD5m7B oawSoX5O0I64ZFjl9PFufQoDrlBlfiKItakJrATPte9oWb8fnoFRgQTTbQJMB32AzI mTYzDpU5o1VfQ== Received: from xiongwei.. (unknown [120.245.2.185]) by pv50p00im-zteg10021301.me.com (Postfix) with ESMTPSA id D0D3FCC0350; Thu, 25 Nov 2021 13:09:41 +0000 (UTC) From: sxwjean@me.com To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Xiongwei Song , Arthur Marsh Subject: [PATCH] mm: page_alloc: Fix building error on -Werror=array-compare Date: Thu, 25 Nov 2021 21:09:28 +0800 Message-Id: <20211125130928.32465-1-sxwjean@me.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425,18.0.790 definitions=2021-11-25_05:2021-11-25,2021-11-25 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=763 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2111250073 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AF08720019D6 X-Stat-Signature: bcunc4798a8mciwzmp7gk9u48kq8qtzf Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=fWEJ8S15; spf=pass (imf26.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.46 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com X-HE-Tag: 1637845800-25594 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Xiongwei Song Arthur Marsh reported we would hit the error below when building kernel with gcc-12: 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) \ | In C++20, the comparision between arrays should be warned. Reported-by: Arthur Marsh Signed-off-by: Xiongwei Song --- 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)