Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: remove annoying namespace_from_kstrtabns()

There are two call sites for sym_update_namespace().

When the symbol has no namespace, s->namespace is set to NULL,
but the conversion from "" to NULL is done in two different places.

[1] read_symbols()

This gets the namespace from __kstrtabns_<symbol>. If the symbol has
no namespace, sym_get_data(info, sym) returns the empty string "".
namespace_from_kstrtabns() converts it to NULL before it is passed to
sym_update_namespace().

[2] read_dump()

This gets the namespace from the dump file, *.symvers. If the symbol
has no namespace, the 'namespace' is the empty string "", which is
directly passed into sym_update_namespace(). The conversion from
"" to NULL is done in sym_update_namespace().

namespace_from_kstrtabns() exists only for creating this inconsistency.

Remove namespace_from_kstrtabns() so that sym_update_namespace() is
consistently passed with "" instead of NULL.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

+2 -12
+2 -12
scripts/mod/modpost.c
··· 369 369 return export_unknown; 370 370 } 371 371 372 - static const char *namespace_from_kstrtabns(const struct elf_info *info, 373 - const Elf_Sym *sym) 374 - { 375 - const char *value = sym_get_data(info, sym); 376 - return value[0] ? value : NULL; 377 - } 378 - 379 372 static void sym_update_namespace(const char *symname, const char *namespace) 380 373 { 381 374 struct symbol *s = find_symbol(symname); ··· 384 391 } 385 392 386 393 free(s->namespace); 387 - s->namespace = 388 - namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL; 394 + s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL; 389 395 } 390 396 391 397 /** ··· 2041 2049 /* Apply symbol namespaces from __kstrtabns_<symbol> entries. */ 2042 2050 if (strstarts(symname, "__kstrtabns_")) 2043 2051 sym_update_namespace(symname + strlen("__kstrtabns_"), 2044 - namespace_from_kstrtabns(&info, 2045 - sym)); 2046 - 2052 + sym_get_data(&info, sym)); 2047 2053 if (strstarts(symname, "__crc_")) 2048 2054 handle_modversion(mod, &info, sym, 2049 2055 symname + strlen("__crc_"));