modpost: traverse the namespace_list in order
Use the doubly linked list to traverse the list in the added order. This makes the code more consistent. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
This commit is contained in:
Родитель
4484054816
Коммит
ab489d6002
|
@ -186,6 +186,8 @@ static struct module *new_module(const char *modname)
|
||||||
memset(mod, 0, sizeof(*mod));
|
memset(mod, 0, sizeof(*mod));
|
||||||
|
|
||||||
INIT_LIST_HEAD(&mod->unresolved_symbols);
|
INIT_LIST_HEAD(&mod->unresolved_symbols);
|
||||||
|
INIT_LIST_HEAD(&mod->missing_namespaces);
|
||||||
|
INIT_LIST_HEAD(&mod->imported_namespaces);
|
||||||
|
|
||||||
strcpy(mod->name, modname);
|
strcpy(mod->name, modname);
|
||||||
mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);
|
mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);
|
||||||
|
@ -288,39 +290,34 @@ static struct symbol *find_symbol(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct namespace_list {
|
struct namespace_list {
|
||||||
struct namespace_list *next;
|
struct list_head list;
|
||||||
char namespace[];
|
char namespace[];
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool contains_namespace(struct namespace_list *list,
|
static bool contains_namespace(struct list_head *head, const char *namespace)
|
||||||
const char *namespace)
|
|
||||||
{
|
{
|
||||||
for (; list; list = list->next)
|
struct namespace_list *list;
|
||||||
|
|
||||||
|
list_for_each_entry(list, head, list) {
|
||||||
if (!strcmp(list->namespace, namespace))
|
if (!strcmp(list->namespace, namespace))
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_namespace(struct namespace_list **list, const char *namespace)
|
static void add_namespace(struct list_head *head, const char *namespace)
|
||||||
{
|
{
|
||||||
struct namespace_list *ns_entry;
|
struct namespace_list *ns_entry;
|
||||||
|
|
||||||
if (!contains_namespace(*list, namespace)) {
|
if (!contains_namespace(head, namespace)) {
|
||||||
ns_entry = NOFAIL(malloc(sizeof(struct namespace_list) +
|
ns_entry = NOFAIL(malloc(sizeof(*ns_entry) +
|
||||||
strlen(namespace) + 1));
|
strlen(namespace) + 1));
|
||||||
strcpy(ns_entry->namespace, namespace);
|
strcpy(ns_entry->namespace, namespace);
|
||||||
ns_entry->next = *list;
|
list_add_tail(&ns_entry->list, head);
|
||||||
*list = ns_entry;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool module_imports_namespace(struct module *module,
|
|
||||||
const char *namespace)
|
|
||||||
{
|
|
||||||
return contains_namespace(module->imported_namespaces, namespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *str;
|
const char *str;
|
||||||
enum export export;
|
enum export export;
|
||||||
|
@ -2190,7 +2187,7 @@ static void check_exports(struct module *mod)
|
||||||
basename = mod->name;
|
basename = mod->name;
|
||||||
|
|
||||||
if (exp->namespace &&
|
if (exp->namespace &&
|
||||||
!module_imports_namespace(mod, exp->namespace)) {
|
!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
|
||||||
modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR,
|
modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR,
|
||||||
"module %s uses symbol %s from namespace %s, but does not import it.\n",
|
"module %s uses symbol %s from namespace %s, but does not import it.\n",
|
||||||
basename, exp->name, exp->namespace);
|
basename, exp->name, exp->namespace);
|
||||||
|
@ -2489,12 +2486,12 @@ static void write_namespace_deps_files(const char *fname)
|
||||||
|
|
||||||
list_for_each_entry(mod, &modules, list) {
|
list_for_each_entry(mod, &modules, list) {
|
||||||
|
|
||||||
if (mod->from_dump || !mod->missing_namespaces)
|
if (mod->from_dump || list_empty(&mod->missing_namespaces))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf_printf(&ns_deps_buf, "%s.ko:", mod->name);
|
buf_printf(&ns_deps_buf, "%s.ko:", mod->name);
|
||||||
|
|
||||||
for (ns = mod->missing_namespaces; ns; ns = ns->next)
|
list_for_each_entry(ns, &mod->missing_namespaces, list)
|
||||||
buf_printf(&ns_deps_buf, " %s", ns->namespace);
|
buf_printf(&ns_deps_buf, " %s", ns->namespace);
|
||||||
|
|
||||||
buf_printf(&ns_deps_buf, "\n");
|
buf_printf(&ns_deps_buf, "\n");
|
||||||
|
|
|
@ -123,9 +123,9 @@ struct module {
|
||||||
struct buffer dev_table_buf;
|
struct buffer dev_table_buf;
|
||||||
char srcversion[25];
|
char srcversion[25];
|
||||||
// Missing namespace dependencies
|
// Missing namespace dependencies
|
||||||
struct namespace_list *missing_namespaces;
|
struct list_head missing_namespaces;
|
||||||
// Actual imported namespaces
|
// Actual imported namespaces
|
||||||
struct namespace_list *imported_namespaces;
|
struct list_head imported_namespaces;
|
||||||
char name[];
|
char name[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче