Re: [PATCH] tools/sched_ext: fix getopt() option variable signedness
From: Tejun Heo
Date: Mon Jun 29 2026 - 12:43:54 EST
On Fri, Jun 26, 2026 at 05:59:28PM +0800, Liang Luo wrote:
> 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@xxxxxxxxxx>
Applied to sched_ext/for-7.3.
Thanks.
--
tejun