From: Qian Cai <cai@lca.pw>
To: mingo@redhat.com, peterz@infradead.org
Cc: valentin.schneider@arm.com, linux-kernel@vger.kernel.org,
Qian Cai <cai@lca.pw>
Subject: [PATCH v3] sched/core: silence a warning in sched_init()
Date: Fri, 19 Jul 2019 12:05:16 -0400 [thread overview]
Message-ID: <1563552316-23391-1-git-send-email-cai@lca.pw> (raw)
Compiling a kernel with both FAIR_GROUP_SCHED=n and RT_GROUP_SCHED=n
will generate a compiler warning,
kernel/sched/core.c: In function 'sched_init':
kernel/sched/core.c:5906:32: warning: variable 'ptr' set but not used
[-Wunused-but-set-variable]
unsigned long alloc_size = 0, ptr;
^~~
Silence it by adding a check in a if statement to actually use it.
Signed-off-by: Qian Cai <cai@lca.pw>
---
v3: Use a different approach to see if Peter will like it.
v2: Incorporate the feedback from Valentin.
kernel/sched/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2b037f195473..ae36a1e5b2e4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6371,7 +6371,8 @@ int in_sched_functions(unsigned long addr)
void __init sched_init(void)
{
- unsigned long alloc_size = 0, ptr;
+ unsigned long alloc_size = 0;
+ unsigned long ptr = 0;
int i;
wait_bit_init();
@@ -6382,7 +6383,8 @@ void __init sched_init(void)
#ifdef CONFIG_RT_GROUP_SCHED
alloc_size += 2 * nr_cpu_ids * sizeof(void **);
#endif
- if (alloc_size) {
+ /* Avoid a -Wunused-but-set-variable warning. */
+ if (alloc_size && !ptr) {
ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
#ifdef CONFIG_FAIR_GROUP_SCHED
--
1.8.3.1
reply other threads:[~2019-07-19 16:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1563552316-23391-1-git-send-email-cai@lca.pw \
--to=cai@lca.pw \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=valentin.schneider@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®