Received: by 10.213.65.68 with SMTP id h4csp1604464imn; Thu, 5 Apr 2018 00:03:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx49YkyQySxcLjRIpu5KS4WPMtHCFVNeWhkhVHcnzssZihjTbGw8nZCHKLxVi6Z4ssQCCRkHP X-Received: by 2002:a17:902:b482:: with SMTP id y2-v6mr20476632plr.394.1522911797301; Thu, 05 Apr 2018 00:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522911797; cv=none; d=google.com; s=arc-20160816; b=bVPxDmzfIKh4r2sUxUg2KAfk4WmkC1uoG/Q+G3jJfK+22DTv5WkiuYvORPFsNS/8a5 eqHl2uede7KHKufLtDGhpa/+6tlOBj0kKVbj1ekIikIOVZ2kXvHqw1My7Yxz6oXwQvNL ukBUibgTjc2cncwyr13yBdI9iDsnH6YlnDXwoOEFbdcQ4WlEAK1eY22UZ8AOffoyXIQb kkqyNFBGMgxas/nlBjKYTpNwQd9lpGRmQ7f+e5W4qAETHcD91ZhKYezDO8k8IuGW1/qv Kv6Z1hTn0GNU9Sk2x4VISaiX8mt2ojU2vJ5XPTxusOxdWngrh+6LginLREAqwLRuG99K dnjg== 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 :content-disposition:mime-version:user-agent:in-reply-to:references :subject:cc:to:from:message-id:date:arc-authentication-results; bh=1spW7+OG1PMwOX6jZO9ZKgsBXf4Kg/vSAboyHOhTztQ=; b=06CtaU0jn9/MZ20FFHNYSEXWlS2pSw5BT44o3njONFvG5zd3f1088cm+If6BlIVq/A V43F00tRs80HYBtIIrp5PvGN7Y012BgH5BniK0IQH+7jCK1o7thKEjV6BGL1haNRgb4l X062DHB0zpruAJPL49rQmPHrns8MyV1l0Im4uGyeB4SIihQe76wz9KbkroFWUu9L+cBw ZWkRffxUvfLm/7PIkJyvOsyqrLXAM3HXVH/dfaZmxunRWlMxdU3KDIKzEPLd7V8B+hTa 1gDLW+BLKCcF7pNQXWLIxnSNrVGR5WSRp8R2vBzxd0dPrWR3cJylE51uxRUuj2e9jjE6 O9OQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si7653559pld.172.2018.04.05.00.03.03; Thu, 05 Apr 2018 00:03:17 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751306AbeDEHB6 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Apr 2018 03:01:58 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:58166 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751233AbeDEHBy (ORCPT ); Thu, 5 Apr 2018 03:01:54 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 40GtzS4zqMz9ttRd; Thu, 5 Apr 2018 09:01:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 9Kn6awbeU3To; Thu, 5 Apr 2018 09:01:40 +0200 (CEST) Received: from vm-hermes.si.c-s.fr (vm-hermes.si.c-s.fr [192.168.25.253]) by pegase1.c-s.fr (Postfix) with ESMTP id 40GtzS4H8Vz9ttBT; Thu, 5 Apr 2018 09:01:40 +0200 (CEST) Received: by vm-hermes.si.c-s.fr (Postfix, from userid 33) id 9F25D25F0; Thu, 5 Apr 2018 09:01:44 +0200 (CEST) Received: from 37-173-23-179.coucou-networks.fr (37-173-23-179.coucou-networks.fr [37.173.23.179]) by messagerie.si.c-s.fr (Horde Framework) with HTTP; Thu, 05 Apr 2018 09:01:44 +0200 Date: Thu, 05 Apr 2018 09:01:44 +0200 Message-ID: <20180405090144.Horde.MbhP02FnROsZKa5LclAqgA6@messagerie.si.c-s.fr> From: LEROY Christophe To: Michael Ellerman Cc: Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Mathieu Malaterre Subject: Re: [PATCH v2 03/19] powerpc: Mark variables as unused References: <20180322202007.23088-4-malat@debian.org> <20180328193307.978-1-malat@debian.org> <20180329181422.Horde.4gvIQbpSZkuyC4Yzg06PKw2@messagerie.si.c-s.fr> <87fu4atct4.fsf@concordia.ellerman.id.au> In-Reply-To: <87fu4atct4.fsf@concordia.ellerman.id.au> User-Agent: Internet Messaging Program (IMP) H5 (6.2.3) Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael Ellerman a écrit : > LEROY Christophe writes: > >> Mathieu Malaterre a écrit : >> >>> Add gcc attribute unused for two variables. Fix warnings treated as errors >>> with W=1: >>> >>> arch/powerpc/kernel/prom_init.c:1388:8: error: variable ‘path’ set >>> but not used [-Werror=unused-but-set-variable] >>> >>> Suggested-by: Christophe Leroy >>> Signed-off-by: Mathieu Malaterre >>> --- >>> v2: move path within ifdef DEBUG_PROM >>> >>> arch/powerpc/kernel/prom_init.c | 6 +++--- >>> 1 file changed, 3 insertions(+), 3 deletions(-) >>> >>> diff --git a/arch/powerpc/kernel/prom_init.c >>> b/arch/powerpc/kernel/prom_init.c >>> index acf4b2e0530c..4163b11abb6c 100644 >>> --- a/arch/powerpc/kernel/prom_init.c >>> +++ b/arch/powerpc/kernel/prom_init.c >>> @@ -603,7 +603,7 @@ static void __init early_cmdline_parse(void) >>> const char *opt; >>> >>> char *p; >>> - int l = 0; >>> + int l __maybe_unused = 0; >>> >>> prom_cmd_line[0] = 0; >>> p = prom_cmd_line; >>> @@ -1385,7 +1385,7 @@ static void __init reserve_mem(u64 base, u64 size) >>> static void __init prom_init_mem(void) >>> { >>> phandle node; >>> - char *path, type[64]; >>> + char *path __maybe_unused, type[64]; >> >> You should enclose that in an ifdef DEBUG_PROM instead of hiding the warning > > I disagree, the result is horrible: > > static void __init prom_init_mem(void) > { > phandle node; > - char *path, type[64]; > +#ifdef DEBUG_PROM > + char *path; > +#endif > + char type[64]; > unsigned int plen; > cell_t *p, *endp; > __be32 val; > > > The right fix is to move the debug logic into a helper, and put the path > in there, eg. something like (not tested): > > diff --git a/arch/powerpc/kernel/prom_init.c > b/arch/powerpc/kernel/prom_init.c > index f9d6befb55a6..b02fa2ccc70b 100644 > --- a/arch/powerpc/kernel/prom_init.c > +++ b/arch/powerpc/kernel/prom_init.c > @@ -1389,6 +1389,18 @@ static void __init reserve_mem(u64 base, u64 size) > mem_reserve_cnt = cnt + 1; > } > > +#ifdef DEBUG_PROM > +static void prom_debug_path(phandle node) > +{ > + char *path; > + path = prom_scratch; > + memset(path, 0, PROM_SCRATCH_SIZE); > + call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1); > + prom_debug(" node %s :\n", path); > +} > +#else > +static void prom_debug_path(phandle node) { } Or put the ifdef inside the function to avoid double definition ? > +#endif /* DEBUG_PROM */ > /* > * Initialize memory allocation mechanism, parse "memory" nodes and > * obtain that way the top of memory and RMO to setup out local allocator > @@ -1441,11 +1453,7 @@ static void __init prom_init_mem(void) > p = regbuf; > endp = p + (plen / sizeof(cell_t)); > > -#ifdef DEBUG_PROM > - memset(path, 0, PROM_SCRATCH_SIZE); > - call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1); > - prom_debug(" node %s :\n", path); > -#endif /* DEBUG_PROM */ > + prom_debug_path(node); > > while ((endp - p) >= (rac + rsc)) { > unsigned long base, size; > > > Although that also begs the question of why the hell do we need path at > all, and not just use prom_scratch directly? Wondering the same, why not use prom_scratch directly Christophe > > cheers