Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3082331pxb; Fri, 4 Feb 2022 00:24:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYtIg5MyvM2u64pFhoymjpZAnAu5KiWn4ku6FfpqcTDqT3WHZma7cXpdkaB7NAoMeFQW+z X-Received: by 2002:a17:907:3f87:: with SMTP id hr7mr1566849ejc.586.1643963043974; Fri, 04 Feb 2022 00:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643963043; cv=none; d=google.com; s=arc-20160816; b=yr4aEs5nS/CUtTGQZXNNeK3ic8zPxQzVUpBVX4xkNOHZXXcbTH8cnBVdn4Ky9e0Tzc DWc0j6s8o1NdJvMMgOObXF18m8W8z1qDBAQR+Jq6WfmWKfX+e/Jtsec7JmhLUyBwPcG+ 1Gf5F4EZhpSsx3g4GG4jyblVpaR+4K02bfmcE8tuvAT8m4YFVEjdfjChtkvnBP0BCQ8+ Zr1iXIjFgMqLZofFoSkeHqqBqD3gkfFs93Y9IaixBok1WczK/ppZYFeDkCvLfnB33XjQ exPB9kBk3BzRtCU0OhizeDSUc2sR4nIGWH4Z2xZyhF8jBKEmyWL8F7uP6154/MlnKJZi aIDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=rP6p3c7eWRXO/WZG4n84i5dELoNm3qpE2agZPlJmCIQ=; b=PhK5G8S9KDOyikQxwQcUuWWDXw8L7e8Obj75QCpJR2Yo99cKSIEHcVlQL0ULEvNFln aAanXYMWi8zvrKTXbPca3vTs+5MR86FURHtqR5AphZH3lCn6i+rQ/om4elPDNSyZmXF2 1IiyCa3F3KPM8IENrved8iixhhJ9VcYVPCbgO2zL8PseX0wzWY+S5eOXPpgnwXjD9Cy0 bvR+JOydDoEYMqzssl1WbB0qVprJINzppppM5yVuRwtgGHWybtD+6z4bv31A/28Tg5LQ ahu3sXVb5wfub7vkCeiw1Q0RDV9wqygNaballCGc8jYlRM/sqlAKgm9UsXnDdGDYCyIF fLzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gKkQ7EC5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho44si887244ejc.237.2022.02.04.00.23.39; Fri, 04 Feb 2022 00:24:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gKkQ7EC5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiBATeK (ORCPT + 99 others); Tue, 1 Feb 2022 14:34:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26905 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbiBATeI (ORCPT ); Tue, 1 Feb 2022 14:34:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643744048; 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=gKkQ7EC59Y6PWtmzLn5E68tjdk5/ICq6pcIdHyaK6lwHz/om7bROsyhe+VDdOr2U0bzMCx n7fgvsnNYmaAWpPIc5d7crNQyFyNDM8WfGFrbOVO+Z1OdttRkkzn5xynIVrDBAGsThYMFL qKTw9tdrWynU4AdTZetgCM/L9i9AhZI= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)])