All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: kernel test robot <lkp@intel.com>
Cc: Yafang Shao <laoar.shao@gmail.com>,
	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
Date: Sat, 11 Sep 2021 14:20:49 +0200	[thread overview]
Message-ID: <20210911122049.GW4323@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <202109110214.oh62aoIq-lkp@intel.com>

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...

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
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 14:20:49 +0200	[thread overview]
Message-ID: <20210911122049.GW4323@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <202109110214.oh62aoIq-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

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...

  parent reply	other threads:[~2021-09-11 12:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 18:21 [peterz-queue:sched/core 13/19] kernel/sched/fair.c:892:34: warning: variable 'stats' set but not used kernel test robot
2021-09-10 18:21 ` kernel test robot
2021-09-11  1:46 ` Yafang Shao
2021-09-11  1:46   ` Yafang Shao
2021-09-11 12:20 ` Peter Zijlstra [this message]
2021-09-11 12:20   ` Peter Zijlstra
2021-09-11 21:30   ` Segher Boessenkool
2021-09-11 21:30     ` Segher Boessenkool
2021-09-11 22:33     ` Peter Zijlstra
2021-09-11 22:33       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210911122049.GW4323@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=kbuild-all@lists.01.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=lkp@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.