Skip to contentSkip to conversation

sched: Fix assignment in if condition in wait_task_inactive

PATCH New XueBing Chen 1 participant 1 message Oct 17, 2025 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: Fix assignment in if condition in wait_task_inactive

Fix checkpatch.pl ERROR: "do not use assignment in if condition"

The code in wait_task_inactive() had an assignment inside an if condition, which violates the kernel coding style. This patch separates the assignment from the conditional check for better readability and maintainability.

---
 kernel/sched/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +2 -1
index 198d2dd45..2dae4cd53 100644
@@ -2305,7 +2305,8 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 		running = task_on_cpu(rq, p);
 		queued = task_on_rq_queued(p);
 		ncsw = 0;
-		if ((match = __task_state_match(p, match_state))) {
+		match = __task_state_match(p, match_state);
+		if (match) {
 			/*
 			 * When matching on p->saved_state, consider this task
 			 * still queued so it will wait.
Signature · 1 line
2.17.1