Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp582033pxb; Sat, 11 Sep 2021 14:39:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrG1qs+lVcLDFRxApbQNqKAx7wEQEHb/7TN3FcRaRz4v9CsYNaRS2MnJrTk62bGx4PaoL3 X-Received: by 2002:a17:906:c18c:: with SMTP id g12mr4698477ejz.458.1631396357809; Sat, 11 Sep 2021 14:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631396357; cv=none; d=google.com; s=arc-20160816; b=0YGK9jSTjQjBoYK9wcI7bjsQXw1X4gJprnjBrcJATg+MxOkK+MOuly5jXK9wIGc62f W7Sk42kLBWiEZTYEFEcngF3xVBo2l6KTnMGfdaIox4sZfdwZSLZQ3qGtME+bX2yBC+qo bNJL799agBVWclr6sxrtiL8lY7tllV/zIoyQUMcGgEx0hVnRBwM1SdYgXrqJNnz/gKnD nlcArYXamNSX/Mw0lUnL4r8kN/MLBbQv+KUZ3+6hDogBuU6aGEYgMhYMDyq5Vrr7MAP0 xl8A1B5mMtRl+YXQISaB6QFZF5N+oWkiW08YLoEtl0dTjQzYVG2LYD3KAUt5xY2a028O xVqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NueHGQUMPf65nMMo47o9lSYteSF0MbHMAvHyXmGv7G8=; b=zvVzzUzlzYVQUWPLhTlyVbyVInComF7V95tw4U5M3rCUon+VXQZKD6vvtBxo4z9SWm HZdhZ+Z95V4IZibj7E25MHcKm0+gTaQgXgHm9HYdCxB4IQr3lnIKHcdhVmQ2K78bqfOA l2SAIzX8hlXSudq1MGF+MbOGsm38w/xwOPQ+WnlujmX1PYVa6VMr1ZIFfK8BnTIl0r4h DNusNU7CyHVz8v+dLjFsrJU2wWsg4jSpT0XuKAqrm/zU9YKdO+tpDG4WTPjugxE2lssa qa3f/gdYidm4ZDVi4nMmkXSLMt372FPGfVOeG7X7eGYrXOJRIqAhqwVpJGQFxPKj8+AZ 5SCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si2819810ejf.317.2021.09.11.14.38.41; Sat, 11 Sep 2021 14:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231690AbhIKVgN (ORCPT + 99 others); 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