tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: compilers and unused args in functions
Am 05.07.2024 um 06:36 schrieb Robert Elz:
> In sh, I have a whole set of functions that are called
> via a function pointer in a data struct
>
> (*p->func)(arg);
>
> One of those functions needs a 2nd arg, which means that
> to keep compatible function profiles these days, I need
> to add the extra arg to all of them
Do you really need all these functions in a single table?
I had a similar situation in usr.bin/make/cond.c from NetBSD 9, where
compare_function had several unrelated functions grouped in a table. The
"exists" function didn't really fit there, as it parses its argument in
a different way and also didn't match the return type of the other
functions. After I split the table, the code was easier to understand
than before.
If adding the second argument is indeed the best choice, you may need to
mark that parameter in all other functions with __unused taken from
<sys/cdefs.h>.
Roland
Home |
Main Index |
Thread Index |
Old Index