From mboxrd@z Thu Jan 1 00:00:00 1970 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 2EE63C433F5 for ; Tue, 1 Feb 2022 19:34:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 494C08D0083; Tue, 1 Feb 2022 14:34:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 44EE48D0077; Tue, 1 Feb 2022 14:34:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30D388D0083; Tue, 1 Feb 2022 14:34:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 20DEA8D0077 for ; Tue, 1 Feb 2022 14:34:08 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BEB428148DDA for ; Tue, 1 Feb 2022 19:34:07 +0000 (UTC) X-FDA: 79095211734.20.4B5B0B7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id C9D6040002 for ; Tue, 1 Feb 2022 19:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643744046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rP6p3c7eWRXO/WZG4n84i5dELoNm3qpE2agZPlJmCIQ=; b=AqAjEfQC7tpwX3gvfuOt8+7JUrF44J+RGcXOBH/hpXeV0UqQ7Ie3p9dAGXeSqtUKEyZEOC 2K7PYi+YuEeawI7ti6uPMepbem8GNQVDm9JYV3E7D5pOweGxRCE+wVJkGCPz/wbKl+01qW g6IzWyGIGB0WJhK3B882Yx0PQ7QUyKs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-MU1fY_yiMcaPbl8FKvQ0Rg-1; Tue, 01 Feb 2022 14:34:05 -0500 X-MC-Unique: MU1fY_yiMcaPbl8FKvQ0Rg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA3F8A0C0A; Tue, 1 Feb 2022 19:34:03 +0000 (UTC) Received: from [10.22.19.61] (unknown [10.22.19.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ECE419C59; Tue, 1 Feb 2022 19:34:02 +0000 (UTC) Message-ID: <79022c90-674a-04d1-0de8-5738df5882b5@redhat.com> Date: Tue, 1 Feb 2022 14:34:02 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] mm/sparsemem: Fix 'mem_section' will never be NULL gcc 12 warning Content-Language: en-US To: Andrew Morton , "Kirill A. Shutemov" , Ingo Molnar Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Justin Forbes , Rafael Aquini References: <20220201192924.672675-1-longman@redhat.com> From: Waiman Long In-Reply-To: <20220201192924.672675-1-longman@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Stat-Signature: 5dwcj5z9oj1mu73mwrsmwa1dcfa51468 X-Rspam-User: nil Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AqAjEfQC; spf=none (imf07.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C9D6040002 X-HE-Tag: 1643744046-792016 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: On 2/1/22 14:29, Waiman Long wrote: > The gcc 12 compiler reports a warning on the following code: > > static inline struct mem_section *__nr_to_section(unsigned long nr) > { > #ifdef CONFIG_SPARSEMEM_EXTREME > if (!mem_section) > return NULL; > #endif > : > > With CONFIG_SPARSEMEM_EXTREME on, the mem_section definition is > > extern struct mem_section **mem_section; > > Obviously, mem_section cannot be NULL, but *mem_section can be if memory > hasn't been allocated for the dynamic mem_section[] array yet. Fix this > warning by checking for "!*mem_section" instead. > > Fixes: 83e3c48729d9 ("mm/sparsemem: Allocate mem_section at runtime for CONFIG_SPARSEMEM_EXTREME=y") Sorry, I forgot to add the line Reported-by: Justin Forbes > Signed-off-by: Waiman Long > --- > include/linux/mmzone.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index aed44e9b5d89..bd1b19925f3b 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -1390,7 +1390,7 @@ static inline unsigned long *section_to_usemap(struct mem_section *ms) > static inline struct mem_section *__nr_to_section(unsigned long nr) > { > #ifdef CONFIG_SPARSEMEM_EXTREME > - if (!mem_section) > + if (!*mem_section) > return NULL; > #endif > if (!mem_section[SECTION_NR_TO_ROOT(nr)])