Skip to contentSkip to conversation

sched/core: avoid assignment in conditional expression

PATCH New Zhan Xusheng 1 participant 1 message Dec 19, 2025 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: avoid assignment in conditional expression

Split the assignment from the conditional expression when matching task state. This improves readability and avoids the use of assignment within an if condition, which is discouraged by the kernel coding style.

No functional change intended.

---
 kernel/sched/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +2 -1
index 41ba0be16911..c7fb7cbec2e1 100644
@@ -2275,7 +2275,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.43.0