mirror of
https://github.com/torvalds/linux.git
synced 2026-09-27 11:02:03 +02:00
tools/sched_ext: fix getopt() option variable signedness
Four example schedulers (scx_simple, scx_cpu0, scx_sdt, scx_userland) declare the variable that holds getopt()'s return value as __u32. getopt() returns int and uses -1 to mark end-of-options; storing that sentinel in an unsigned variable turns it into 0xffffffff, and the subsequent 'opt != -1' test only happens to keep working because both operands of != are promoted to the same 0xffffffff. Declare the variable as __s32 instead, matching getopt()'s actual contract and the style already used in scx_qmap.c (int opt) and scx_pair/central/flatcg.c (__s32 opt). This also silences the -Wsign-compare warnings emitted for the affected files. Signed-off-by: Liang Luo <luoliang@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
e2c60e15d0
commit
0cfd929fba
|
|
@ -62,7 +62,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
struct scx_cpu0 *skel;
|
||||
struct bpf_link *link;
|
||||
__u32 opt;
|
||||
__s32 opt;
|
||||
__u64 ecode;
|
||||
|
||||
libbpf_set_print(libbpf_print_fn);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
struct scx_sdt *skel;
|
||||
struct bpf_link *link;
|
||||
__u32 opt;
|
||||
__s32 opt;
|
||||
__u64 ecode;
|
||||
|
||||
libbpf_set_print(libbpf_print_fn);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
struct scx_simple *skel;
|
||||
struct bpf_link *link;
|
||||
__u32 opt;
|
||||
__s32 opt;
|
||||
__u64 ecode;
|
||||
|
||||
libbpf_set_print(libbpf_print_fn);
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ static int spawn_stats_thread(void)
|
|||
static void pre_bootstrap(int argc, char **argv)
|
||||
{
|
||||
int err;
|
||||
__u32 opt;
|
||||
__s32 opt;
|
||||
struct sched_param sched_param = {
|
||||
.sched_priority = sched_get_priority_max(SCHED_EXT),
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user