[PATCH] sched/core: avoid assignment in conditional expression

Zhan Xusheng posted 1 patch 1 month, 2 weeks ago
kernel/sched/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] sched/core: avoid assignment in conditional expression
Posted by Zhan Xusheng 1 month, 2 weeks ago
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.

Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
 kernel/sched/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 41ba0be16911..c7fb7cbec2e1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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.
-- 
2.43.0