[Swan-dev] style: naming of parameters should match in function prototype and definition
D. Hugh Redelmeier
hugh at mimosa.com
Sat Jun 13 22:31:32 UTC 2020
I just noticed an example where our code violates this.
The function prototype for initsubnet:
extern err_t initsubnet(const ip_address *addr, int maskbits, int clash,
The start of its definition:
err_t /* NULL for success, else string literal */
initsubnet(addr, count, clash, dst)
const ip_address * addr;
int clash; /* '0' zero host-part bits, 'x' die on them */
The second argument is called "maskbits" in the prototype and "count"
in the definition.
The documentation (lib/libswan/initsubnet.3.xml) calls it maskbits.
This is legal.
I think that it is quite confusing
I can think of no advantage.
Conclusion: we should avoid this.
(Technical detail that doesn't concern our project:
Parameter names are local to the function or function prototype. If
you are building library code and want to reduce possible name clashes
with macros, you might choose not to name the parameters in the
function prototype in the .h file. I think that impairs readability.)
We should probably convert everything from old style function
definitions. I don't see this as urgent.
More information about the Swan-dev