Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5223636ybf; Wed, 4 Mar 2020 20:04:33 -0800 (PST) X-Google-Smtp-Source: ADFU+vvrgGZXJgQOtcoXL9WnrMan0Hfiy9BVmCnwjduAmxOjmvAFoTIcSsaN6KegTKhK6/vM/Pma X-Received: by 2002:aca:5757:: with SMTP id l84mr4403168oib.56.1583381073545; Wed, 04 Mar 2020 20:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583381073; cv=none; d=google.com; s=arc-20160816; b=MGcLBqfBT89jXQLrHE5NYq8TGRIXHfP7n+g5UYjONt2X3ncHiZ02HjClWepNevvCp2 krjFtBreG+8MXSx0oh9q8KQ2J0ZOdB+Z3u1PjLqMKSoBs4/WESwcaFd247bqdiH8TFeN 7dRBCQ6FZa7PKReuCiEdYGmBaL7CpPbSrFWNNQgh5LQTouJ1uAra+DKkwlWxXDzzEbd9 5VOPhQpy2Xv2Gr3eRcO+HoNqdOJPROsl7mdNlCNgXqM3JfXdgmjnuodYwwu/QhEJVeJW NE78m4RAjI81NvriuL2xlEjs5w8R4kCJjIi4KLgm8OFH8n9S7LE8VTUuzCz3fS8QFQGL OTCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=VklxRdhjEuCIVv9HPoUaXq6mGuwwwTdi/ln0LYnVDsY=; b=qtP7RbJROs9ScQWKnhI/NOhO9mPX0tWWxXeuCynguy5uaQ0FRC+kBCJkENrUYhNURj 4OjGppBbVvrJ9a4HHGm8QuzE2W5haEMxcQtXofz+7ke1DzuwaLN5Apk3Hy75fkFn7KoW GA9aWnQJr4ELeKpl8444E8fW2Xh7llk8/5DLkTqFxdq+Bo7lqdLLS3HZNYI/k5PNo6Dm 0djLGt0JpVXE6V+CC1/1b8OdxwHO8/DQIRdiqpYvnvu0V/LduyO39TJzC1Q8LU/IXo+3 E0RXB9/MiVWR61Zu5gx0aVrOl2My+XqelVqUslZkl1Nybzp9g6/nE0v17kXifxf7mX2S zo5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iqjN7sn1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 18si2306170oiq.71.2020.03.04.20.04.21; Wed, 04 Mar 2020 20:04:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iqjN7sn1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725965AbgCEEDk (ORCPT + 99 others); Wed, 4 Mar 2020 23:03:40 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35194 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgCEEDk (ORCPT ); Wed, 4 Mar 2020 23:03:40 -0500 Received: by mail-lf1-f68.google.com with SMTP id z9so3400896lfa.2 for ; Wed, 04 Mar 2020 20:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VklxRdhjEuCIVv9HPoUaXq6mGuwwwTdi/ln0LYnVDsY=; b=iqjN7sn1fgP8MPUCuQpmzoScaDl1FaFzxx3l1cao6LafOPa8aFbH28X7nrCPhLRAbR qtXG+jrOx+0IPwQTh8T0OpSSV6eVDvOi2nVHr+AMlvWLKSoWxo9JoXpKQMXHEZjbZdIP Eg0P7foQARhwfsw4LDg3rxTBm0PfMExB/HPfcvvQU6OCxEiMKA+A7donE9uK7TQxxHGd Tlb/uDyhYeWMxsBDSAv3jUoA+bsPBAJ+mBd165pbvxkgbsChGGXYU/liBCc22CPvI+Bi u5S/sz/Q0IsWdmEYawIM+0cbJg3IigCvSnjnEwRb3eJSdmZoLWTq9uMqepeF8ts+1lF1 PH+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VklxRdhjEuCIVv9HPoUaXq6mGuwwwTdi/ln0LYnVDsY=; b=g0pu3AQSStkWWwdVIMp0fxu/H9QhXV3r6F3C5ldt9+ZrTqiV+/jqCy5UT5Rb3ZkAd4 wLt+bMM85zrHikN2BgsYmXM7tvBqGUCZ0XRnWpyYCyae4TrPOnKiTXbHJVIrobGvNo1h EY8IH/C5xnIBULvReJoFRsHUw3O3B7Cu6QfiTzI2ztT0SEjiK9hj9zmyNkQIeGIm6lXc usOqxpfdabYPPjzFUuplUpCM7bnU6y/Rbr158U+uBQPr/QzJW0h+iVNI8Gp+moqsJiUM 51Afog2PjyDqV1ouooYBEZ/8XASYFJlZ/efkALLrdeqikSUxvnTm36Arsl6fZHFAPBvK LhPw== X-Gm-Message-State: ANhLgQ0XUHV3R/8B0eiTaftT15RasfTnG5zPBkoukAOC1fBvs5dBwT75 ncmlGEO9FQf2GlHCn9T7nVO3numGB5Dv5DuYaHc= X-Received: by 2002:ac2:5f62:: with SMTP id c2mr4094191lfc.207.1583381017663; Wed, 04 Mar 2020 20:03:37 -0800 (PST) MIME-Version: 1.0 References: <20200303065210.1279-1-zhenzhong.duan@gmail.com> <20200303065210.1279-3-zhenzhong.duan@gmail.com> In-Reply-To: From: Zhenzhong Duan Date: Thu, 5 Mar 2020 12:03:26 +0800 Message-ID: Subject: Re: [PATCH 2/2] x86/boot/KASLR: Fix unused variable warning To: Dave Hansen Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Borislav Petkov , "H. Peter Anvin" , Dave Hansen , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 4, 2020 at 6:56 AM Dave Hansen wrote: > > On 3/2/20 10:52 PM, Zhenzhong Duan wrote: > > Local variable 'i' is referenced only when CONFIG_MEMORY_HOTREMOVE and > > CONFIG_ACPI are defined, but definition of variable 'i' is out of guard= . > > If any of the two macros is undefined, below warning triggers during > > build, fix it by moving 'i' in the guard. > > > > arch/x86/boot/compressed/kaslr.c:698:6: warning: unused variable =E2=80= =98i=E2=80=99 [-Wunused-variable] > ... > > diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compresse= d/kaslr.c > > index d7408af55738..62bc46684581 100644 > > --- a/arch/x86/boot/compressed/kaslr.c > > +++ b/arch/x86/boot/compressed/kaslr.c > > @@ -695,7 +695,6 @@ static bool process_mem_region(struct mem_vector *r= egion, > > unsigned long long minimum, > > unsigned long long image_size) > > { > > - int i; > > /* > > * If no immovable memory found, or MEMORY_HOTREMOVE disabled, > > * use @region directly. > > @@ -711,6 +710,7 @@ static bool process_mem_region(struct mem_vector *r= egion, > > } > > > > #if defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI) > > + int i; > > Won't this just result in a different warning since it now it will > declare 'i' in the middle of the function once CONFIG_MEMORY_HOTREMOVE > and ACPI are enabled? I didn't see a different warning with both configs enabled, because -std=3Dgnu89 isn't enforced in arch/x86/boot/compressed but it does in other part of kernel. C99 and above allows declaration in middule of the function. Zhenzhong