Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal

From: Peter Zijlstra
Date: Mon Dec 02 2024 - 10:21:49 EST


On Mon, Dec 02, 2024 at 03:59:47PM +0100, Peter Zijlstra wrote:
> Clean up the existing export namespace code along the same lines of
> 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to
> __section("foo")") and for the same reason, it is not desired for the
> namespace argument to be a macro expansion itself.
>
> git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
> do
> awk -i inplace '
> /^#define EXPORT_SYMBOL_NS/ {
> gsub(/__stringify\(ns\)/, "ns");
> print;
> next;
> }
> /^#define MODULE_IMPORT_NS/ {
> gsub(/__stringify\(ns\)/, "ns");
> print;
> next;
> }
> /MODULE_IMPORT_NS/ {
> $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
> }
> /EXPORT_SYMBOL_NS/ {
> if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
> if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
> $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
> $0 !~ /^my/) {
> getline line;
> gsub(/[[:space:]]*\\$/, "");
> gsub(/[[:space:]]/, "", line);
> $0 = $0 " " line;
> }
>
> $0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
> "\\1(\\2, \"\\3\")", "g");
> }
> }
> { print }' $file;
> done

Perhaps we can ask Linus to run this now, before -next fills up again ?

> Requested-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>