[SLOF] [PATCH slof 08/13] libnet: Compile with -Wextra

Segher Boessenkool segher at kernel.crashing.org
Tue Feb 2 12:00:33 AEDT 2021


Hi!

On Sun, Jan 31, 2021 at 02:54:08PM +1100, Alexey Kardashevskiy wrote:
> >I'd rather vote for keeping -Wno-unused-parameter. Otherwise you're 
> >always forced to write silly code or use __attribute__((unused)) when a 
> >function has to match a certain parameter list, e.g. because it is used 
> >as a function pointer later, and that's rather annoying.
> 
> Then why pass them around? I understand if it is a callback of some sort 
> and not all instances may need additional parameters but this is not the 
> case here.
> 
> And passing around 3 zeroes - domain/type/proto is as stupid, I am 
> basically commenting on what is supported in socket(). Thanks,

Fwiw, from GCC 11 on (so not too useful for you yet) you can leave out
the name of unused parameters, just like in C++.  (Older compilers say
"error: parameter name omitted").

If you want to name it anyway (as documentation perhaps), you can
comment that, like
  void f(int a, int /*b*/) { return 42*a; }
but in cases like yours you can often just say
  void f(int a, int) { return 42*a; }


Segher


More information about the SLOF mailing list