All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dhruva Gole <d-gole@ti.com>
To: Frederic Weisbecker <frederic@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>
Cc: Chen Yu <yu.c.chen@intel.com>, <linux-kernel@vger.kernel.org>,
	Kees Cook <kees@kernel.org>, Randy Dunlap <rdunlap@infradead.org>,
	Dhruva Gole <d-gole@ti.com>
Subject: [PATCH V2] kthread: Fix build warning variable 'ret' set but not used
Date: Tue, 4 Feb 2025 21:39:21 +0530	[thread overview]
Message-ID: <20250204160921.377178-1-d-gole@ti.com> (raw)
In-Reply-To: <20250204090838.214647-1-d-gole@ti.com>

Fix the following build time warning in kthread:

   kernel/kthread.c: In function 'kthread_affine_preferred':
>> kernel/kthread.c:861:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
     861 |         int ret;
         |             ^~~

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501301528.t0cZVbnq-lkp@intel.com/
Signed-off-by: Dhruva Gole <d-gole@ti.com>
---
Link to v1:
https://lore.kernel.org/lkml/20250204090838.214647-1-d-gole@ti.com/

Changelog:
- Use ret value toward the end return as per Kees' suggestion

---

 kernel/kthread.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 4005b13ebd7f..5dc5b0d7238e 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -859,7 +859,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
 	struct kthread *kthread = to_kthread(p);
 	cpumask_var_t affinity;
 	unsigned long flags;
-	int ret;
+	int ret = 0;
 
 	if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE) || kthread->started) {
 		WARN_ON(1);
@@ -892,7 +892,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
 out:
 	free_cpumask_var(affinity);
 
-	return 0;
+	return ret;
 }
 
 /*

base-commit: 40b8e93e17bff4a4e0cc129e04f9fdf5daa5397e
-- 
2.34.1


  parent reply	other threads:[~2025-02-04 16:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30  7:16 kernel/kthread.c:861:13: warning: variable 'ret' set but not used kernel test robot
2025-02-04  9:08 ` [PATCH] kthread: Fix build warning " Dhruva Gole
2025-02-04 15:15   ` Kees Cook
2025-02-04 15:50     ` Dhruva Gole
2025-02-04 16:09   ` Dhruva Gole [this message]
2025-02-04 19:02     ` [PATCH V2] " Frederic Weisbecker
2025-02-05  6:17       ` Dhruva Gole
2025-02-05 11:09         ` Frederic Weisbecker

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=20250204160921.377178-1-d-gole@ti.com \
    --to=d-gole@ti.com \
    --cc=akpm@linux-foundation.org \
    --cc=frederic@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=vbabka@suse.cz \
    --cc=yu.c.chen@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.