mirror of https://gitee.com/openkylin/linux.git
modpost: delegate updating namespaces to separate function
Let the function 'sym_update_namespace' take care of updating the namespace for a symbol. While this currently only replaces one single location where namespaces are updated, in a following patch, this function will get more call sites. The function signature is intentionally close to sym_update_crc and taking the name by char* seems like unnecessary work as the symbol has to be looked up again. In a later patch of this series, this concern will be addressed. This function ensures that symbol::namespace is either NULL or has a valid non-empty value. Previously, the empty string was considered 'no namespace' as well and this lead to confusion. Acked-by: Will Deacon <will@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Jessica Yu <jeyu@kernel.org>
This commit is contained in:
parent
4f5cafb5cb
commit
a2b1118438
|
@ -362,6 +362,25 @@ static char *sym_extract_namespace(const char **symname)
|
||||||
return namespace;
|
return namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sym_update_namespace(const char *symname, const char *namespace)
|
||||||
|
{
|
||||||
|
struct symbol *s = find_symbol(symname);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* That symbol should have been created earlier and thus this is
|
||||||
|
* actually an assertion.
|
||||||
|
*/
|
||||||
|
if (!s) {
|
||||||
|
merror("Could not update namespace(%s) for symbol %s\n",
|
||||||
|
namespace, symname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(s->namespace);
|
||||||
|
s->namespace =
|
||||||
|
namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an exported symbol - it may have already been added without a
|
* Add an exported symbol - it may have already been added without a
|
||||||
* CRC, in this case just update the CRC
|
* CRC, in this case just update the CRC
|
||||||
|
@ -383,8 +402,7 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace,
|
||||||
s->module = mod;
|
s->module = mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(s->namespace);
|
sym_update_namespace(name, namespace);
|
||||||
s->namespace = namespace ? strdup(namespace) : NULL;
|
|
||||||
s->preloaded = 0;
|
s->preloaded = 0;
|
||||||
s->vmlinux = is_vmlinux(mod->name);
|
s->vmlinux = is_vmlinux(mod->name);
|
||||||
s->kernel = 0;
|
s->kernel = 0;
|
||||||
|
@ -2196,7 +2214,7 @@ static int check_exports(struct module *mod)
|
||||||
else
|
else
|
||||||
basename = mod->name;
|
basename = mod->name;
|
||||||
|
|
||||||
if (exp->namespace && exp->namespace[0]) {
|
if (exp->namespace) {
|
||||||
add_namespace(&mod->required_namespaces,
|
add_namespace(&mod->required_namespaces,
|
||||||
exp->namespace);
|
exp->namespace);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue