Skip to contentSkip to conversation

sched_ext: Add missing braces to multi-line blocks

PATCH In review Cheng-Yang Chou 2 participants 4 messages Mar 2 – Mar 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_ext: Add missing braces to multi-line blocks

Add braces around outer loops and conditionals that contain multi-line inner statements in both ext.c and ext_idle.c.

According to the kernel maintainer tip bracket rules, brackets should only be omitted if the statement following an 'if' or 'for' is truly a single line. This improves reading flow and prevents future errors.

---
 kernel/sched/ext.c      | 6 ++++--
 kernel/sched/ext_idle.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
kernel/sched/ext.c +4 -2
index 9280381f8923..8fcee252d30e 100644
@@ -5038,9 +5038,10 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 		sch->exit_info->flags |= SCX_EFLAG_INITIALIZED;
 	}
 
-	for (i = SCX_OPI_CPU_HOTPLUG_BEGIN; i < SCX_OPI_CPU_HOTPLUG_END; i++)
+	for (i = SCX_OPI_CPU_HOTPLUG_BEGIN; i < SCX_OPI_CPU_HOTPLUG_END; i++) {
 		if (((void (**)(void))ops)[i])
 			set_bit(i, sch->has_op);
+	}
 
 	ret = check_hotplug_seq(sch, ops);
 	if (ret) {
@@ -5084,9 +5085,10 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 	scx_bypass(true);
 	scx_bypassed_for_enable = true;
 
-	for (i = SCX_OPI_NORMAL_BEGIN; i < SCX_OPI_NORMAL_END; i++)
+	for (i = SCX_OPI_NORMAL_BEGIN; i < SCX_OPI_NORMAL_END; i++) {
 		if (((void (**)(void))ops)[i])
 			set_bit(i, sch->has_op);
+	}
 
 	if (sch->ops.cpu_acquire || sch->ops.cpu_release)
 		sch->ops.flags |= SCX_OPS_HAS_CPU_PREEMPT;
kernel/sched/ext_idle.c +4 -2
index e2da6c3968a6..22bf96753f1c 100644
@@ -323,9 +323,10 @@ static bool llc_numa_mismatch(void)
 	 * overlapping, which is incorrect (as NUMA 1 has two distinct LLC
 	 * domains).
 	 */
-	for_each_online_cpu(cpu)
+	for_each_online_cpu(cpu) {
 		if (llc_weight(cpu) != numa_weight(cpu))
 			return true;
+	}
 
 	return false;
 }
@@ -752,9 +753,10 @@ void __scx_update_idle(struct rq *rq, bool idle, bool do_notify)
 	 * In this way we can avoid updating the idle masks twice,
 	 * unnecessarily.
 	 */
-	if (static_branch_likely(&scx_builtin_idle_enabled))
+	if (static_branch_likely(&scx_builtin_idle_enabled)) {
 		if (do_notify || is_idle_task(rq->curr))
 			update_builtin_idle(cpu, idle);
+	}
 
 	/*
 	 * Trigger ops.update_idle() only when transitioning from a task to
Signature · 1 line
2.48.1
#1 lore raw
Quoted 9 lines · Cheng-Yang Chou

Add braces around outer loops and conditionals that contain multi-line inner statements in both ext.c and ext_idle.c.

According to the kernel maintainer tip bracket rules, brackets should only be omitted if the statement following an 'if' or 'for' is truly a single line. This improves reading flow and prevents future errors.

Gentle ping on this minor style fix.
No rush at all, just making sure it didn't slip by.

Signature · 2 lines
Thanks,
Cheng-Yang
reviewer
#2 lore raw

Hello,

Quoted 8 lines · Cheng-Yang Chou
Quoted 7 lines · Cheng-Yang Chou

Add braces around outer loops and conditionals that contain multi-line inner statements in both ext.c and ext_idle.c.

According to the kernel maintainer tip bracket rules, brackets should only be omitted if the statement following an 'if' or 'for' is truly a single line. This improves reading flow and prevents future errors.

Quoted 5 lines
Quoted 2 lines

Gentle ping on this minor style fix.
No rush at all, just making sure it didn't slip by.

I don't think these trivial patches are useful. Ask yourself, is the code meaningfully better afterwards? Maybe as a part of some other big changes, these might make sense, but, by themselves, it's just noise, a busy work. Please don't send these patches.

Thanks.

Signature · 1 line
tejun
#3 lore raw
Quoted 17 lines · Tejun Heo

Hello,

Quoted 8 lines · Cheng-Yang Chou
Quoted 7 lines · Cheng-Yang Chou

Add braces around outer loops and conditionals that contain multi-line inner statements in both ext.c and ext_idle.c.

According to the kernel maintainer tip bracket rules, brackets should only be omitted if the statement following an 'if' or 'for' is truly a single line. This improves reading flow and prevents future errors.

Quoted 5 lines
Quoted 2 lines

Gentle ping on this minor style fix.
No rush at all, just making sure it didn't slip by.

Quoted 9 lines

I don't think these trivial patches are useful. Ask yourself, is the code meaningfully better afterwards? Maybe as a part of some other big changes, these might make sense, but, by themselves, it's just noise, a busy work. Please don't send these patches.

Thanks.

Signature · 1 line
tejun

Understood.
Thanks for the feedback!

Signature · 2 lines
Thanks,
Cheng-Yang