kernel/sched/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
From: Liang Luo <luoliang@kylinos.cn>
The kernel coding style recommends using 'else if' instead of
placing 'if' on a separate line after 'else'. This change makes
the code consistent with the rest of the kernel codebase.
Signed-off-by: Liang Luo <luoliang@kylinos.cn>
---
kernel/sched/core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index da20fb6ea25a..c2bf0fc6ac97 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3716,8 +3716,7 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,
en_flags |= ENQUEUE_RQ_SELECTED;
if (wake_flags & WF_MIGRATED)
en_flags |= ENQUEUE_MIGRATED;
- else
- if (p->in_iowait) {
+ else if (p->in_iowait) {
delayacct_blkio_end(p);
atomic_dec(&task_rq(p)->nr_iowait);
}
--
2.45.0
On 13/05/26 16:54, luoliang@kylinos.cn wrote:
> From: Liang Luo <luoliang@kylinos.cn>
>
> The kernel coding style recommends using 'else if' instead of
> placing 'if' on a separate line after 'else'. This change makes
> the code consistent with the rest of the kernel codebase.
>
> Signed-off-by: Liang Luo <luoliang@kylinos.cn>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Seems to be the only one in kernel/, a quick coccinelle script tells me
there's:
kernel/events/core.c:12160:3-7: ERROR: else (line 12160) and if (line 12162) should be on same line as 'else if'
kernel/sched/core.c:3727:1-5: ERROR: else (line 3727) and if (line 3728) should be on same line as 'else if'
kernel/seccomp.c:734:3-7: ERROR: else (line 734) and if (line 736) should be on same line as 'else if'
but the two other ones are legit uses (#ifdef faffery).
A quick look at the whole tree suggests there may be a few other places to
fix. Anywho, if you want to play around:
---
// SPDX-License-Identifier: GPL-2.0-only
/// Detect separate 'else' and 'if' that should be combined as 'else if'
///
// Confidence: High
// Copyright: (C) 2026 Valentin Schneider, Red Hat
// Comments:
// Options: --no-includes --include-headers
virtual report
@r depends on report@
expression E1, E2;
position p1, p2;
@@
if (E1) {
...
}
else@p1
if@p2 (E2) {
...
}
@script:python@
p1 << r.p1;
p2 << r.p2;
@@
if p1[0].line != p2[0].line:
msg = "WARNING: split 'else if' at lines %s & %s" % (p1[0].line, p2[0].line)
coccilib.report.print_report(p1[0], msg)
© 2016 - 2026 Red Hat, Inc.