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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76D79C433EF for ; Sat, 11 Sep 2021 21:35:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F844611C0 for ; Sat, 11 Sep 2021 21:35:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234142AbhIKVgN (ORCPT ); Sat, 11 Sep 2021 17:36:13 -0400 Received: from gate.crashing.org ([63.228.1.57]:56833 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbhIKVgM (ORCPT ); Sat, 11 Sep 2021 17:36:12 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 18BLUhGl030275; Sat, 11 Sep 2021 16:30:43 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 18BLUfuG030274; Sat, 11 Sep 2021 16:30:41 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Sat, 11 Sep 2021 16:30:41 -0500 From: Segher Boessenkool To: Peter Zijlstra Cc: kernel test robot , Yafang Shao , kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, linux-toolchains@vger.kernel.org Subject: Re: [peterz-queue:sched/core 13/19] kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used Message-ID: <20210911213041.GD1583@gate.crashing.org> References: <202109110214.oh62aoIq-lkp@intel.com> <20210911122049.GW4323@worktop.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210911122049.GW4323@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On Sat, Sep 11, 2021 at 02:20:49PM +0200, Peter Zijlstra wrote: > On Sat, Sep 11, 2021 at 02:21:26AM +0800, kernel test robot wrote: > > compiler: m68k-linux-gcc (GCC) 11.2.0 > > > kernel/sched/fair.c: In function 'update_curr': > > kernel/sched/fair.c:860:42: warning: unused variable 'stats' [-Wunused-variable] > > 860 | struct sched_statistics *stats = __schedstats_from_se(curr); > > | ^~~~~ > > OK, compiler guys, this code reads like: > > #define schedstats_enabled() (0) > #define __schedstat_set(x, y) do { } while (0) > > > if (schedstats_enabled()) { > struct sched_statistics *stats = __schedstats_from_se(curr); > > __schedstat_set(stats->exec_max, > max(delta_exec, stats->exec_max)); > } > > So yes, we initialize a variable that then isn't used, but the whole > bloody thing is inside if (0) which will not ever get ran *anyway*. > > This is a crap warning if ever I saw one... Yes, we really should warn "do not use a preprocessor macro if what you want is a function"? The variable really *is* unused, with this macro. If we would remove dead code before warning about unused variables there would be many *more* false positives, fwiw. Segher From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7968063768393174697==" MIME-Version: 1.0 From: Segher Boessenkool To: kbuild-all@lists.01.org Subject: Re: [peterz-queue:sched/core 13/19] kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used Date: Sat, 11 Sep 2021 16:30:41 -0500 Message-ID: <20210911213041.GD1583@gate.crashing.org> In-Reply-To: <20210911122049.GW4323@worktop.programming.kicks-ass.net> List-Id: --===============7968063768393174697== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi! On Sat, Sep 11, 2021 at 02:20:49PM +0200, Peter Zijlstra wrote: > On Sat, Sep 11, 2021 at 02:21:26AM +0800, kernel test robot wrote: > > compiler: m68k-linux-gcc (GCC) 11.2.0 > = > > kernel/sched/fair.c: In function 'update_curr': > > kernel/sched/fair.c:860:42: warning: unused variable 'stats' [-Wunus= ed-variable] > > 860 | struct sched_statistics *stats =3D __schedst= ats_from_se(curr); > > | ^~~~~ > = > OK, compiler guys, this code reads like: > = > #define schedstats_enabled() (0) > #define __schedstat_set(x, y) do { } while (0) > = > = > if (schedstats_enabled()) { > struct sched_statistics *stats =3D __schedstats_from_se(curr); > = > __schedstat_set(stats->exec_max, > max(delta_exec, stats->exec_max)); > } > = > So yes, we initialize a variable that then isn't used, but the whole > bloody thing is inside if (0) which will not ever get ran *anyway*. > = > This is a crap warning if ever I saw one... Yes, we really should warn "do not use a preprocessor macro if what you want is a function"? The variable really *is* unused, with this macro. If we would remove dead code before warning about unused variables there would be many *more* false positives, fwiw. Segher --===============7968063768393174697==--