Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Misleading error reporting when pthread_create fails due to reliance on errno.
--
--- Patch [5]: [PATCH 5/9] KVM: selftests: Add KVM syscall wrapper for pthread_create() ---
commit c5c266b1e7b797f8b82c5a3cecf097ba6720b060
Author: Sean Christopherson <[email protected]>
KVM: selftests: Add KVM syscall wrapper for pthread_create()
This commit adds a KVM wrapper for pthread_create() to eliminate manual
success assertions in selftests. It replaces direct calls to pthread_create()
with kvm_pthread_create() across multiple test files.
> diff --git a/tools/testing/selftests/kvm/include/kvm_syscalls.h b/tools/testing/selftests/kvm/include/kvm_syscalls.h
> --- a/tools/testing/selftests/kvm/include/kvm_syscalls.h
> +++ b/tools/testing/selftests/kvm/include/kvm_syscalls.h
[ ... ]
> @@ -96,6 +97,10 @@ __KVM_SYSCALL_DEFINE(ftruncate, 2, unsigned int, fd, off_t, length);
> __KVM_SYSCALL_DEFINE(madvise, 3, void *, addr, size_t, length, int, advice);
> __KVM_SYSCALL_DEFINE(sched_getaffinity, 3, pid_t, pid, size_t, cpusetsize, cpu_set_t *, mask);
>
> +typedef void *(*pthread_fn_t)(void *);
> +__KVM_SYSCALL_DEFINE(pthread_create, 4, pthread_t *, thread,
> + const pthread_attr_t *, attr, pthread_fn_t, fn, void *, arg);
[Severity: Low]
Does this lead to misleading error messages on failure?
The __KVM_SYSCALL_DEFINE macro seems to assume the wrapped function sets errno
on failure, which gets printed when the test asserts via __KVM_SYSCALL_ERROR.
However, pthread_create() returns its error code directly rather than setting
errno.
If thread creation fails, it looks like the test framework might print a
misleading message containing "errno: 0 (Success)" alongside the actual
non-zero return code. Should this use a different wrapper or assert strategy
that handles direct error returns?
> +
> #define kvm_free_fd(fd) \
> do { \
> kvm_close(fd); \
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.