sched_ext: Fix function pointer type mismatches in BPF selftests
Subsystems (2)
PATCH 1/1 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.
--- .../selftests/sched_ext/create_dsq.bpf.c | 6 +- .../sched_ext/ddsp_bogus_dsq_fail.bpf.c | 4 +- .../sched_ext/ddsp_vtimelocal_fail.bpf.c | 4 +- .../selftests/sched_ext/dsp_local_on.bpf.c | 8 +-- .../sched_ext/enq_select_cpu_fails.bpf.c | 4 +- tools/testing/selftests/sched_ext/exit.bpf.c | 14 ++--- .../testing/selftests/sched_ext/hotplug.bpf.c | 8 +-- .../sched_ext/init_enable_count.bpf.c | 8 +-- .../testing/selftests/sched_ext/maximal.bpf.c | 58 +++++++++---------- .../selftests/sched_ext/maybe_null.bpf.c | 6 +- .../sched_ext/maybe_null_fail_dsp.bpf.c | 4 +- .../sched_ext/maybe_null_fail_yld.bpf.c | 4 +- .../selftests/sched_ext/prog_run.bpf.c | 2 +- .../selftests/sched_ext/select_cpu_dfl.bpf.c | 2 +- .../sched_ext/select_cpu_dfl_nodispatch.bpf.c | 6 +- .../sched_ext/select_cpu_dispatch.bpf.c | 2 +- .../select_cpu_dispatch_bad_dsq.bpf.c | 4 +- .../select_cpu_dispatch_dbl_dsp.bpf.c | 4 +- .../sched_ext/select_cpu_vtime.bpf.c | 12 ++-- 19 files changed, 80 insertions(+), 80 deletions(-)
tools/testing/selftests/sched_ext/create_dsq.bpf.c +3 -3
@@ -51,8 +51,8 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(create_dsq_init) SEC(".struct_ops.link")struct sched_ext_ops create_dsq_ops = { - .init_task = create_dsq_init_task, - .exit_task = create_dsq_exit_task, - .init = create_dsq_init, + .init_task = (void *) create_dsq_init_task, + .exit_task = (void *) create_dsq_exit_task, + .init = (void *) create_dsq_init, .name ="create_dsq" , };
tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c +2 -2
@@ -35,8 +35,8 @@ void BPF_STRUCT_OPS(ddsp_bogus_dsq_fail_exit, struct scx_exit_info *ei) SEC(".struct_ops.link")struct sched_ext_ops ddsp_bogus_dsq_fail_ops = { - .select_cpu = ddsp_bogus_dsq_fail_select_cpu, - .exit = ddsp_bogus_dsq_fail_exit, + .select_cpu = (void *) ddsp_bogus_dsq_fail_select_cpu, + .exit = (void *) ddsp_bogus_dsq_fail_exit, .name ="ddsp_bogus_dsq_fail" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c +2 -2
@@ -32,8 +32,8 @@ void BPF_STRUCT_OPS(ddsp_vtimelocal_fail_exit, struct scx_exit_info *ei) SEC(".struct_ops.link")struct sched_ext_ops ddsp_vtimelocal_fail_ops = { - .select_cpu = ddsp_vtimelocal_fail_select_cpu, - .exit = ddsp_vtimelocal_fail_exit, + .select_cpu = (void *) ddsp_vtimelocal_fail_select_cpu, + .exit = (void *) ddsp_vtimelocal_fail_exit, .name ="ddsp_vtimelocal_fail" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/dsp_local_on.bpf.c +4 -4
@@ -56,10 +56,10 @@ void BPF_STRUCT_OPS(dsp_local_on_exit, struct scx_exit_info *ei) SEC(".struct_ops.link")struct sched_ext_ops dsp_local_on_ops = { - .select_cpu = dsp_local_on_select_cpu, - .enqueue = dsp_local_on_enqueue, - .dispatch = dsp_local_on_dispatch, - .exit = dsp_local_on_exit, + .select_cpu = (void *) dsp_local_on_select_cpu, + .enqueue = (void *) dsp_local_on_enqueue, + .dispatch = (void *) dsp_local_on_dispatch, + .exit = (void *) dsp_local_on_exit, .name ="dsp_local_on" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c +2 -2
@@ -36,8 +36,8 @@ void BPF_STRUCT_OPS(enq_select_cpu_fails_enqueue, struct task_struct *p, SEC(".struct_ops.link")struct sched_ext_ops enq_select_cpu_fails_ops = { - .select_cpu = enq_select_cpu_fails_select_cpu, - .enqueue = enq_select_cpu_fails_enqueue, + .select_cpu = (void *) enq_select_cpu_fails_select_cpu, + .enqueue = (void *) enq_select_cpu_fails_enqueue, .name ="enq_select_cpu_fails" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/exit.bpf.c +7 -7
@@ -72,13 +72,13 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(exit_init) SEC(".struct_ops.link")struct sched_ext_ops exit_ops = { - .select_cpu = exit_select_cpu, - .enqueue = exit_enqueue, - .dispatch = exit_dispatch, - .init_task = exit_init_task, - .enable = exit_enable, - .exit = exit_exit, - .init = exit_init, + .select_cpu = (void *) exit_select_cpu, + .enqueue = (void *) exit_enqueue, + .dispatch = (void *) exit_dispatch, + .init_task = (void *) exit_init_task, + .enable = (void *) exit_enable, + .exit = (void *) exit_exit, + .init = (void *) exit_init, .name ="exit" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/hotplug.bpf.c +4 -4
@@ -46,16 +46,16 @@ void BPF_STRUCT_OPS_SLEEPABLE(hotplug_cpu_offline, s32 cpu) SEC(".struct_ops.link")struct sched_ext_ops hotplug_cb_ops = { - .cpu_online = hotplug_cpu_online, - .cpu_offline = hotplug_cpu_offline, - .exit = hotplug_exit, + .cpu_online = (void *) hotplug_cpu_online, + .cpu_offline = (void *) hotplug_cpu_offline, + .exit = (void *) hotplug_exit, .name ="hotplug_cbs" , .timeout_ms =1000U , }; SEC(".struct_ops.link")struct sched_ext_ops hotplug_nocb_ops = { - .exit = hotplug_exit, + .exit = (void *) hotplug_exit, .name ="hotplug_nocbs" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/init_enable_count.bpf.c +4 -4
@@ -45,9 +45,9 @@ void BPF_STRUCT_OPS(cnt_disable, struct task_struct *p) SEC(".struct_ops.link")struct sched_ext_ops init_enable_count_ops = { - .init_task = cnt_init_task, - .exit_task = cnt_exit_task, - .enable = cnt_enable, - .disable = cnt_disable, + .init_task = (void *) cnt_init_task, + .exit_task = (void *) cnt_exit_task, + .enable = (void *) cnt_enable, + .disable = (void *) cnt_disable, .name ="init_enable_count" , };
tools/testing/selftests/sched_ext/maximal.bpf.c +29 -29
63 lines not on this page · raw message
tools/testing/selftests/sched_ext/maybe_null.bpf.c +3 -3
@@ -29,8 +29,8 @@ bool BPF_STRUCT_OPS(maybe_null_success_yield, struct task_struct *from, SEC(".struct_ops.link")struct sched_ext_ops maybe_null_success = { - .dispatch = maybe_null_success_dispatch, - .yield = maybe_null_success_yield, - .enable = maybe_null_running, + .dispatch = (void *) maybe_null_success_dispatch, + .yield = (void *) maybe_null_success_yield, + .enable = (void *) maybe_null_running, .name ="minimal" , };
tools/testing/selftests/sched_ext/maybe_null_fail_dsp.bpf.c +2 -2
@@ -19,7 +19,7 @@ void BPF_STRUCT_OPS(maybe_null_fail_dispatch, s32 cpu, struct task_struct *p) SEC(".struct_ops.link")struct sched_ext_ops maybe_null_fail = { - .dispatch = maybe_null_fail_dispatch, - .enable = maybe_null_running, + .dispatch = (void *) maybe_null_fail_dispatch, + .enable = (void *) maybe_null_running, .name ="maybe_null_fail_dispatch" , };
tools/testing/selftests/sched_ext/maybe_null_fail_yld.bpf.c +2 -2
@@ -22,7 +22,7 @@ bool BPF_STRUCT_OPS(maybe_null_fail_yield, struct task_struct *from, SEC(".struct_ops.link")struct sched_ext_ops maybe_null_fail = { - .yield = maybe_null_fail_yield, - .enable = maybe_null_running, + .yield = (void *) maybe_null_fail_yield, + .enable = (void *) maybe_null_running, .name ="maybe_null_fail_yield" , };
tools/testing/selftests/sched_ext/prog_run.bpf.c +1 -1
@@ -28,6 +28,6 @@ void BPF_STRUCT_OPS(prog_run_exit, struct scx_exit_info *ei) SEC(".struct_ops.link")struct sched_ext_ops prog_run_ops = { - .exit = prog_run_exit, + .exit = (void *) prog_run_exit, .name ="prog_run" , };
tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c +1 -1
@@ -35,6 +35,6 @@ void BPF_STRUCT_OPS(select_cpu_dfl_enqueue, struct task_struct *p, SEC(".struct_ops.link")struct sched_ext_ops select_cpu_dfl_ops = { - .enqueue = select_cpu_dfl_enqueue, + .enqueue = (void *) select_cpu_dfl_enqueue, .name ="select_cpu_dfl" , };
tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c +3 -3
@@ -82,8 +82,8 @@ s32 BPF_STRUCT_OPS(select_cpu_dfl_nodispatch_init_task, SEC(".struct_ops.link")struct sched_ext_ops select_cpu_dfl_nodispatch_ops = { - .select_cpu = select_cpu_dfl_nodispatch_select_cpu, - .enqueue = select_cpu_dfl_nodispatch_enqueue, - .init_task = select_cpu_dfl_nodispatch_init_task, + .select_cpu = (void *) select_cpu_dfl_nodispatch_select_cpu, + .enqueue = (void *) select_cpu_dfl_nodispatch_enqueue, + .init_task = (void *) select_cpu_dfl_nodispatch_init_task, .name ="select_cpu_dfl_nodispatch" , };
tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c +1 -1
@@ -35,7 +35,7 @@ s32 BPF_STRUCT_OPS(select_cpu_dispatch_select_cpu, struct task_struct *p, SEC(".struct_ops.link")struct sched_ext_ops select_cpu_dispatch_ops = { - .select_cpu = select_cpu_dispatch_select_cpu, + .select_cpu = (void *) select_cpu_dispatch_select_cpu, .name ="select_cpu_dispatch" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c +2 -2
@@ -30,8 +30,8 @@ void BPF_STRUCT_OPS(select_cpu_dispatch_bad_dsq_exit, struct scx_exit_info *ei) SEC(".struct_ops.link")struct sched_ext_ops select_cpu_dispatch_bad_dsq_ops = { - .select_cpu = select_cpu_dispatch_bad_dsq_select_cpu, - .exit = select_cpu_dispatch_bad_dsq_exit, + .select_cpu = (void *) select_cpu_dispatch_bad_dsq_select_cpu, + .exit = (void *) select_cpu_dispatch_bad_dsq_exit, .name ="select_cpu_dispatch_bad_dsq" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c +2 -2
@@ -31,8 +31,8 @@ void BPF_STRUCT_OPS(select_cpu_dispatch_dbl_dsp_exit, struct scx_exit_info *ei) SEC(".struct_ops.link")struct sched_ext_ops select_cpu_dispatch_dbl_dsp_ops = { - .select_cpu = select_cpu_dispatch_dbl_dsp_select_cpu, - .exit = select_cpu_dispatch_dbl_dsp_exit, + .select_cpu = (void *) select_cpu_dispatch_dbl_dsp_select_cpu, + .exit = (void *) select_cpu_dispatch_dbl_dsp_exit, .name ="select_cpu_dispatch_dbl_dsp" , .timeout_ms =1000U , };
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c +6 -6
@@ -81,12 +81,12 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(select_cpu_vtime_init) SEC(".struct_ops.link")struct sched_ext_ops select_cpu_vtime_ops = { - .select_cpu = select_cpu_vtime_select_cpu, - .dispatch = select_cpu_vtime_dispatch, - .running = select_cpu_vtime_running, - .stopping = select_cpu_vtime_stopping, - .enable = select_cpu_vtime_enable, - .init = select_cpu_vtime_init, + .select_cpu = (void *) select_cpu_vtime_select_cpu, + .dispatch = (void *) select_cpu_vtime_dispatch, + .running = (void *) select_cpu_vtime_running, + .stopping = (void *) select_cpu_vtime_stopping, + .enable = (void *) select_cpu_vtime_enable, + .init = (void *) select_cpu_vtime_init, .name ="select_cpu_vtime" , .timeout_ms =1000U , };
Signature · 1 line
2.47.0
Quoted 9 lines · Vishal Chourasia
Fix incompatible function pointer type warnings in
sched_extBPF selftests by explicitly casting the function pointers when initializingstruct_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]>
Applied to sched_ext/for-6.12-fixes.
Thanks.
Signature · 1 line
tejun