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

Petr Vorel pvorel@suse.cz
Mon Nov 4 10:13:05 CET 2024


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.

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 */
 #endif
 
 #ifndef HAVE_CLONE3


More information about the ltp mailing list