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

Willy Tarreau w at 1wt.eu
Sat Sep 16 19:58:51 PDT 2023


On Thu, Sep 14, 2023 at 06:01:18PM +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.

Just out of curiosity, did you find a valid case for enabling this
warning or were you trying various combinations ? I'm asking because
I've never seen it enabled anywhere given that it's probably the most 
useless and unusable warning: as soon as you're dealing with function
pointers, you start to have multiple functions with a similar
prototype, some of which just don't need certain arguments, and the
only way to shut the warning is to significantly uglify the code.

If really needed, I'm wondering if instead we shouldn't have an
"no_syscall*" set of macros, that would have the same signature
as my_syscall* to just consume all args in the same order and
return -ENOSYS. E.g, consider the following:

  @@ -934,6 +960,11 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
   #endif
   	return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
   #else
  +	(void)nfds;
  +	(void)rfds;
  +	(void)wfds;
  +	(void)efds;
  +	(void)timeout;
   	return -ENOSYS;
   #endif

It would become:

  @@ -934,6 +960,11 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
   #endif
   	return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
   #else
  +	return no_syscall5(nfds, rfds, wfds, efds, timeout);
  -	return -ENOSYS;
   #endif

What do you think ?

Thanks!
Willy



More information about the linux-riscv mailing list