[PATCH v2 2/4] tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks

Willy Tarreau w at 1wt.eu
Mon Sep 18 09:19:15 PDT 2023


Hi Thomas,

On Sun, Sep 17, 2023 at 05:36:17PM +0200, Thomas Weißschuh wrote:
> The ENOSYS fallback code does not use its functions parameters.
> This can lead to compiler warnings about unused parameters.
> 
> Explicitly avoid these warnings.
> 
> Signed-off-by: Thomas Weißschuh <linux at weissschuh.net>
> ---
>  tools/include/nolibc/sys.h | 44 +++++++++++++++++++++++++++-----------------
>  1 file changed, 27 insertions(+), 17 deletions(-)
> 
> diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> index b478750c9004..8389820e1928 100644
> --- a/tools/include/nolibc/sys.h
> +++ b/tools/include/nolibc/sys.h
> @@ -43,6 +43,16 @@
>  		: __sysret_arg;                         /* return original value */ \
>  })
>  
> +/* Syscall ENOSYS helper: Avoids unused-parameter warnings and provides a
> + * debugging hook.
> + */
> +
> +static __inline__ int __nolibc_enosys(const char *syscall, ...)
> +{
> +	(void)syscall;
> +	return -ENOSYS;
> +}
> +
>  
>  /* Functions in this file only describe syscalls. They're declared static so
>   * that the compiler usually decides to inline them while still being allowed
> @@ -133,7 +143,7 @@ int sys_chmod(const char *path, mode_t mode)
>  #elif defined(__NR_chmod)
>  	return my_syscall2(__NR_chmod, path, mode);
>  #else
> -	return -ENOSYS;
> +	return __nolibc_enosys(__func__, path, mode);
>  #endif
>  }
(...)

It's much cleaner like this.

Acked-by: Willy Tarreau <w at 1wt.eu>

Feel free to push the whole series to the next branch.

Thank you!
Willy



More information about the linux-riscv mailing list