Skip to content

Commit 4f7f417

Browse files
vishalc-ibmhtejun
authored andcommitted
sched_ext: Fix function pointer type mismatches in BPF selftests
Fix incompatible function pointer type warnings in sched_ext BPF selftests by explicitly casting the function pointers when initializing struct_ops. This addresses multiple -Wincompatible-function-pointer-types warnings from the clang compiler where function signatures didn't match exactly. The void * cast ensures the compiler accepts the function pointer assignment despite minor type differences in the parameters. Signed-off-by: Vishal Chourasia <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 9b3c11a commit 4f7f417

19 files changed

+80
-80
lines changed

tools/testing/selftests/sched_ext/create_dsq.bpf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(create_dsq_init)
5151

5252
SEC(".struct_ops.link")
5353
struct sched_ext_ops create_dsq_ops = {
54-
.init_task = create_dsq_init_task,
55-
.exit_task = create_dsq_exit_task,
56-
.init = create_dsq_init,
54+
.init_task = (void *) create_dsq_init_task,
55+
.exit_task = (void *) create_dsq_exit_task,
56+
.init = (void *) create_dsq_init,
5757
.name = "create_dsq",
5858
};

tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void BPF_STRUCT_OPS(ddsp_bogus_dsq_fail_exit, struct scx_exit_info *ei)
3535

3636
SEC(".struct_ops.link")
3737
struct sched_ext_ops ddsp_bogus_dsq_fail_ops = {
38-
.select_cpu = ddsp_bogus_dsq_fail_select_cpu,
39-
.exit = ddsp_bogus_dsq_fail_exit,
38+
.select_cpu = (void *) ddsp_bogus_dsq_fail_select_cpu,
39+
.exit = (void *) ddsp_bogus_dsq_fail_exit,
4040
.name = "ddsp_bogus_dsq_fail",
4141
.timeout_ms = 1000U,
4242
};

tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ void BPF_STRUCT_OPS(ddsp_vtimelocal_fail_exit, struct scx_exit_info *ei)
3232

3333
SEC(".struct_ops.link")
3434
struct sched_ext_ops ddsp_vtimelocal_fail_ops = {
35-
.select_cpu = ddsp_vtimelocal_fail_select_cpu,
36-
.exit = ddsp_vtimelocal_fail_exit,
35+
.select_cpu = (void *) ddsp_vtimelocal_fail_select_cpu,
36+
.exit = (void *) ddsp_vtimelocal_fail_exit,
3737
.name = "ddsp_vtimelocal_fail",
3838
.timeout_ms = 1000U,
3939
};

tools/testing/selftests/sched_ext/dsp_local_on.bpf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ void BPF_STRUCT_OPS(dsp_local_on_exit, struct scx_exit_info *ei)
5656

5757
SEC(".struct_ops.link")
5858
struct sched_ext_ops dsp_local_on_ops = {
59-
.select_cpu = dsp_local_on_select_cpu,
60-
.enqueue = dsp_local_on_enqueue,
61-
.dispatch = dsp_local_on_dispatch,
62-
.exit = dsp_local_on_exit,
59+
.select_cpu = (void *) dsp_local_on_select_cpu,
60+
.enqueue = (void *) dsp_local_on_enqueue,
61+
.dispatch = (void *) dsp_local_on_dispatch,
62+
.exit = (void *) dsp_local_on_exit,
6363
.name = "dsp_local_on",
6464
.timeout_ms = 1000U,
6565
};

tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void BPF_STRUCT_OPS(enq_select_cpu_fails_enqueue, struct task_struct *p,
3636

3737
SEC(".struct_ops.link")
3838
struct sched_ext_ops enq_select_cpu_fails_ops = {
39-
.select_cpu = enq_select_cpu_fails_select_cpu,
40-
.enqueue = enq_select_cpu_fails_enqueue,
39+
.select_cpu = (void *) enq_select_cpu_fails_select_cpu,
40+
.enqueue = (void *) enq_select_cpu_fails_enqueue,
4141
.name = "enq_select_cpu_fails",
4242
.timeout_ms = 1000U,
4343
};

tools/testing/selftests/sched_ext/exit.bpf.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(exit_init)
7272

7373
SEC(".struct_ops.link")
7474
struct sched_ext_ops exit_ops = {
75-
.select_cpu = exit_select_cpu,
76-
.enqueue = exit_enqueue,
77-
.dispatch = exit_dispatch,
78-
.init_task = exit_init_task,
79-
.enable = exit_enable,
80-
.exit = exit_exit,
81-
.init = exit_init,
75+
.select_cpu = (void *) exit_select_cpu,
76+
.enqueue = (void *) exit_enqueue,
77+
.dispatch = (void *) exit_dispatch,
78+
.init_task = (void *) exit_init_task,
79+
.enable = (void *) exit_enable,
80+
.exit = (void *) exit_exit,
81+
.init = (void *) exit_init,
8282
.name = "exit",
8383
.timeout_ms = 1000U,
8484
};

tools/testing/selftests/sched_ext/hotplug.bpf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ void BPF_STRUCT_OPS_SLEEPABLE(hotplug_cpu_offline, s32 cpu)
4646

4747
SEC(".struct_ops.link")
4848
struct sched_ext_ops hotplug_cb_ops = {
49-
.cpu_online = hotplug_cpu_online,
50-
.cpu_offline = hotplug_cpu_offline,
51-
.exit = hotplug_exit,
49+
.cpu_online = (void *) hotplug_cpu_online,
50+
.cpu_offline = (void *) hotplug_cpu_offline,
51+
.exit = (void *) hotplug_exit,
5252
.name = "hotplug_cbs",
5353
.timeout_ms = 1000U,
5454
};
5555

5656
SEC(".struct_ops.link")
5757
struct sched_ext_ops hotplug_nocb_ops = {
58-
.exit = hotplug_exit,
58+
.exit = (void *) hotplug_exit,
5959
.name = "hotplug_nocbs",
6060
.timeout_ms = 1000U,
6161
};

tools/testing/selftests/sched_ext/init_enable_count.bpf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ void BPF_STRUCT_OPS(cnt_disable, struct task_struct *p)
4545

4646
SEC(".struct_ops.link")
4747
struct sched_ext_ops init_enable_count_ops = {
48-
.init_task = cnt_init_task,
49-
.exit_task = cnt_exit_task,
50-
.enable = cnt_enable,
51-
.disable = cnt_disable,
48+
.init_task = (void *) cnt_init_task,
49+
.exit_task = (void *) cnt_exit_task,
50+
.enable = (void *) cnt_enable,
51+
.disable = (void *) cnt_disable,
5252
.name = "init_enable_count",
5353
};

tools/testing/selftests/sched_ext/maximal.bpf.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,34 +131,34 @@ void BPF_STRUCT_OPS(maximal_exit, struct scx_exit_info *info)
131131

132132
SEC(".struct_ops.link")
133133
struct sched_ext_ops maximal_ops = {
134-
.select_cpu = maximal_select_cpu,
135-
.enqueue = maximal_enqueue,
136-
.dequeue = maximal_dequeue,
137-
.dispatch = maximal_dispatch,
138-
.runnable = maximal_runnable,
139-
.running = maximal_running,
140-
.stopping = maximal_stopping,
141-
.quiescent = maximal_quiescent,
142-
.yield = maximal_yield,
143-
.core_sched_before = maximal_core_sched_before,
144-
.set_weight = maximal_set_weight,
145-
.set_cpumask = maximal_set_cpumask,
146-
.update_idle = maximal_update_idle,
147-
.cpu_acquire = maximal_cpu_acquire,
148-
.cpu_release = maximal_cpu_release,
149-
.cpu_online = maximal_cpu_online,
150-
.cpu_offline = maximal_cpu_offline,
151-
.init_task = maximal_init_task,
152-
.enable = maximal_enable,
153-
.exit_task = maximal_exit_task,
154-
.disable = maximal_disable,
155-
.cgroup_init = maximal_cgroup_init,
156-
.cgroup_exit = maximal_cgroup_exit,
157-
.cgroup_prep_move = maximal_cgroup_prep_move,
158-
.cgroup_move = maximal_cgroup_move,
159-
.cgroup_cancel_move = maximal_cgroup_cancel_move,
160-
.cgroup_set_weight = maximal_cgroup_set_weight,
161-
.init = maximal_init,
162-
.exit = maximal_exit,
134+
.select_cpu = (void *) maximal_select_cpu,
135+
.enqueue = (void *) maximal_enqueue,
136+
.dequeue = (void *) maximal_dequeue,
137+
.dispatch = (void *) maximal_dispatch,
138+
.runnable = (void *) maximal_runnable,
139+
.running = (void *) maximal_running,
140+
.stopping = (void *) maximal_stopping,
141+
.quiescent = (void *) maximal_quiescent,
142+
.yield = (void *) maximal_yield,
143+
.core_sched_before = (void *) maximal_core_sched_before,
144+
.set_weight = (void *) maximal_set_weight,
145+
.set_cpumask = (void *) maximal_set_cpumask,
146+
.update_idle = (void *) maximal_update_idle,
147+
.cpu_acquire = (void *) maximal_cpu_acquire,
148+
.cpu_release = (void *) maximal_cpu_release,
149+
.cpu_online = (void *) maximal_cpu_online,
150+
.cpu_offline = (void *) maximal_cpu_offline,
151+
.init_task = (void *) maximal_init_task,
152+
.enable = (void *) maximal_enable,
153+
.exit_task = (void *) maximal_exit_task,
154+
.disable = (void *) maximal_disable,
155+
.cgroup_init = (void *) maximal_cgroup_init,
156+
.cgroup_exit = (void *) maximal_cgroup_exit,
157+
.cgroup_prep_move = (void *) maximal_cgroup_prep_move,
158+
.cgroup_move = (void *) maximal_cgroup_move,
159+
.cgroup_cancel_move = (void *) maximal_cgroup_cancel_move,
160+
.cgroup_set_weight = (void *) maximal_cgroup_set_weight,
161+
.init = (void *) maximal_init,
162+
.exit = (void *) maximal_exit,
163163
.name = "maximal",
164164
};

tools/testing/selftests/sched_ext/maybe_null.bpf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ bool BPF_STRUCT_OPS(maybe_null_success_yield, struct task_struct *from,
2929

3030
SEC(".struct_ops.link")
3131
struct sched_ext_ops maybe_null_success = {
32-
.dispatch = maybe_null_success_dispatch,
33-
.yield = maybe_null_success_yield,
34-
.enable = maybe_null_running,
32+
.dispatch = (void *) maybe_null_success_dispatch,
33+
.yield = (void *) maybe_null_success_yield,
34+
.enable = (void *) maybe_null_running,
3535
.name = "minimal",
3636
};

0 commit comments

Comments
 (0)