[LTP] [PATCH] syscalls/sched_getattr02: use a fixed size for EINVAL test

Jan Stancek jstancek@redhat.com
Mon Nov 4 10:53:49 CET 2024


On Mon, Nov 4, 2024 at 10:13 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan, Li,
>
> > Jan Stancek <jstancek@redhat.com> wrote:
>
>
> > > -       {&pid, &attr_copy, sizeof(struct sched_attr) - 1, 0, EINVAL},
> > > +       {&pid, &attr_copy, 47, 0, EINVAL},
>
> LGTM. But using "SCHED_ATTR_SIZE_VER0 - 1" would be more descriptive than magic
> number 47. But for that we would need to add a fallaback definition to
> include/lapi/sched.h. But sure, it's described in the commit message, thus
> documented.

OK, pushed with the usage of define SCHED_ATTR_SIZE_VER0.

>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> > "EINVAL size is invalid; that is, it is smaller than the initial version of
> > the sched_attr structure (48 bytes) or larger than the system page size."
>
> > Or we could add one more item for testing 'page_size + 1'.
>
> +1 (having to tests).
>
> Kind regards,
> Petr
>
> > Anyway, this workaround looks good.
> > Reviewed-by: Li Wang <liwang@redhat.com>
>
> +++ include/lapi/sched.h
> @@ -46,6 +46,8 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
>  {
>         return syscall(__NR_sched_getattr, pid, attr, size, flags);
>  }
> +#else
> +# define SCHED_ATTR_SIZE_VER0  48      /* sizeof first published struct */

^^ not in else branch, the check is "ifndef", so that's where it needs
to be defined



More information about the ltp mailing list