Re: [PATCH] module: Allow DEFAULT_SYMBOL_NAMESPACE be set after export.h included
From: David Laight
Date: Sat Dec 28 2024 - 19:59:48 EST
On Sat, 28 Dec 2024 15:29:24 -0800
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Sat, 28 Dec 2024 at 10:43, David Laight <david.laight.linux@xxxxxxxxx> wrote:
> >
> > Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the
> > extra _EXPORT_SYMBOL() wrapper.
> >
> > This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.
>
> Grr. This is horribly ugly.
I thought it was a neater 'ugly' than the current definitions in export.h
> I think the i2c code should just be fixed to use the proper "define
> namespace early".
The i2c changes were needed because I found the code wouldn't compile.
It is pretty easy mistake to make and will happen again.
and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c
and drivers/pwm/pwm-lpss.c
I guess those files could be fixed by moving the definition 'early'.
> I will also note that 'sparse' has a notion of a "weak define", where
> you can set a default value for a preprocessor symbol, but if it gets
> redefined by the user (or already has a definition), sparse won't
> complain about it, and just use the strong one.
>
> That would have been lovely, and we could have had a
>
> #weak_define DEFAULT_SYMBOL_NAMESPACE ""
>
> and this wouldn't be the ugly mess it is.
>
> I wish the regular C preprocessor could do the same. Oh well. Since it
> doesn't, I really think i2c should just be fixed, and we shouldn't try
> to deal with i2c having done things wrong.
What you really need is the preprocessor to support a ?: type operator
in an expansion. Then you can have (DEFAULT_SYMBOL_NAMESPACE ?: "") in
the expansion of EXPORT_SYMBOL().
>
> Linus