Re: [PATCH v2 08/12] KVM: selftests: Add KVM syscall wrapper for pthread_create()
[email protected] Fri, 31 Jul 2026 17:20:10 +0000
| Newsgroups | dev.linux.lists.kvmarm,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Using `__KVM_SYSCALL_DEFINE` to wrap `pthread_create` results in misleading error messages on failure, as it logs `errno` instead of the returned error code. -- --- Patch [8]: [PATCH v2 08/12] KVM: selftests: Add KVM syscall wrapper for pthread_create() --- commit dca849bcf7bfa248030e1f22bebefccde9e01db3 Author: Sean Christopherson <[email protected]> KVM: selftests: Add KVM syscall wrapper for pthread_create() This commit adds a wrapper for the pthread_create() syscall to the KVM selftests. It replaces manual error checking across the selftests with the new wrapper which automatically asserts success. [ ... ] > diff --git a/tools/testing/selftests/kvm/include/kvm_syscalls.h b/tools/testing/selftests/kvm/include/kvm_syscalls.h > index 01dca99009c2f..e75be83787798 100644 > --- a/tools/testing/selftests/kvm/include/kvm_syscalls.h > +++ b/tools/testing/selftests/kvm/include/kvm_syscalls.h [ ... ] > @@ -97,6 +98,10 @@ __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); > __KVM_SYSCALL_DEFINE(sched_setaffinity, 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 wrapper format the error message correctly on failure? The __KVM_SYSCALL_DEFINE macro uses __KVM_SYSCALL_ERROR to format the error string, which reads errno and uses strerror(errno). However, POSIX specifies that pthread_create returns the error code directly and does not set errno. If pthread_create fails, wouldn't this print a stale errno, or print "Success" if errno happened to be zero, rather than reporting the actual returned error code? -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=8