Re: [PATCH 3/6] cyclictest: Fix error error returns for uclibc clock_nanosleep() fallback

Florian Bezdeka <[email protected]> Tue, 07 Apr 2026 10:16:08 +0200
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
On Tue, 2026-04-07 at 08:48 +0200, Thomas Weißschuh (Schneider Electric)
wrote:
> clock_nanosleep() is expected to return errors as a positive number,
> without relying on errno.
> 
> Signed-off-by: Thomas Weißschuh (Schneider Electric) <[email protected]>
> ---
>  src/cyclictest/cyclictest.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index 0c30e767e685..dacf0b7a718e 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -62,12 +62,18 @@
>  static int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *req,
>  			   struct timespec *rem)
>  {
> +	int retval;
> +
>  	if (clock_id == CLOCK_THREAD_CPUTIME_ID)
>  		return -EINVAL;
>  	if (clock_id == CLOCK_PROCESS_CPUTIME_ID)
>  		clock_id = MAKE_PROCESS_CPUCLOCK(0, CPUCLOCK_SCHED);
>  
> -	return syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
> +	retval = syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
> +	if (retval == 0)
> +		return 0;
> +
> +	return errno;

That doesn't match with the commit message above, does it? syscall() to
my knowledge will not set/touch errno. syscall() will return whatever
came back from the kernel.

The value of errno is "undefined" (in terms of "contains the last error
code, wherever this is coming from") here.

Looking at patch 4: Looks like this patch can be dropped.

>  }
>  
>  int sched_setaffinity(__pid_t __pid, size_t __cpusetsize,
> 
> -- 
> 2.53.0