History

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.

Masahiro Yamada committed 4 years ago

Commit ab489d61 parent 44840542 files · +17 −20Browse files

Showing the changes to scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. scripts/mod/modpost.c +15 −18
  2. scripts/mod/modpost.h +2 −2
scripts/mod/modpost.c+15−18
@@ -186,6 +186,8 @@ static struct module *new_module(const char *modname) · 185 unmodified lines
186 memset(mod, 0, sizeof(*mod));186 memset(mod, 0, sizeof(*mod));
187 187
188 INIT_LIST_HEAD(&mod->unresolved_symbols);188 INIT_LIST_HEAD(&mod->unresolved_symbols);
189 INIT_LIST_HEAD(&mod->missing_namespaces);
190 INIT_LIST_HEAD(&mod->imported_namespaces);
189 191
190 strcpy(mod->name, modname);192 strcpy(mod->name, modname);
191 mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);193 mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);
@@ -288,39 +290,34 @@ static struct symbol *find_symbol(const char *name) · 96 unmodified lines
288}290}
289 291
290struct namespace_list {292struct namespace_list {
291 struct namespace_list *next;293 struct list_head list;
292 char namespace[];294 char namespace[];
293};295};
294 296
295static bool contains_namespace(struct namespace_list *list,297static bool contains_namespace(struct list_head *head, const char *namespace)
296 const char *namespace)
297{298{
298 for (; list; list = list->next)299 struct namespace_list *list;
300
301 list_for_each_entry(list, head, list) {
299 if (!strcmp(list->namespace, namespace))302 if (!strcmp(list->namespace, namespace))
300 return true;303 return true;
304 }
301 305
302 return false;306 return false;
303}307}
304 308
305static void add_namespace(struct namespace_list **list, const char *namespace)309static void add_namespace(struct list_head *head, const char *namespace)
306{310{
307 struct namespace_list *ns_entry;311 struct namespace_list *ns_entry;
308 312
309 if (!contains_namespace(*list, namespace)) {313 if (!contains_namespace(head, namespace)) {
310 ns_entry = NOFAIL(malloc(sizeof(struct namespace_list) +314 ns_entry = NOFAIL(malloc(sizeof(*ns_entry) +
311 strlen(namespace) + 1));315 strlen(namespace) + 1));
312 strcpy(ns_entry->namespace, namespace);316 strcpy(ns_entry->namespace, namespace);
313 ns_entry->next = *list;317 list_add_tail(&ns_entry->list, head);
314 *list = ns_entry;
315 }318 }
316}319}
317 320
318static bool module_imports_namespace(struct module *module,
319 const char *namespace)
320{
321 return contains_namespace(module->imported_namespaces, namespace);
322}
323
324static const struct {321static const struct {
325 const char *str;322 const char *str;
326 enum export export;323 enum export export;
@@ -2190,7 +2187,7 @@ static void check_exports(struct module *mod) · 1863 unmodified lines
2190 basename = mod->name;2187 basename = mod->name;
2191 2188
2192 if (exp->namespace &&2189 if (exp->namespace &&
2193 !module_imports_namespace(mod, exp->namespace)) {2190 !contains_namespace(&mod->imported_namespaces, exp->namespace)) {
2194 modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR,2191 modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR,
2195 "module %s uses symbol %s from namespace %s, but does not import it.\n",2192 "module %s uses symbol %s from namespace %s, but does not import it.\n",
2196 basename, exp->name, exp->namespace);2193 basename, exp->name, exp->namespace);
@@ -2489,12 +2486,12 @@ static void write_namespace_deps_files(const char *fname) · 292 unmodified lines
2489 2486
2490 list_for_each_entry(mod, &modules, list) {2487 list_for_each_entry(mod, &modules, list) {
2491 2488
2492 if (mod->from_dump || !mod->missing_namespaces)2489 if (mod->from_dump || list_empty(&mod->missing_namespaces))
2493 continue;2490 continue;
2494 2491
2495 buf_printf(&ns_deps_buf, "%s.ko:", mod->name);2492 buf_printf(&ns_deps_buf, "%s.ko:", mod->name);
2496 2493
2497 for (ns = mod->missing_namespaces; ns; ns = ns->next)2494 list_for_each_entry(ns, &mod->missing_namespaces, list)
2498 buf_printf(&ns_deps_buf, " %s", ns->namespace);2495 buf_printf(&ns_deps_buf, " %s", ns->namespace);
2499 2496
2500 buf_printf(&ns_deps_buf, "\n");2497 buf_printf(&ns_deps_buf, "\n");
scripts/mod/modpost.h+2−2
@@ -123,9 +123,9 @@ struct module { · 122 unmodified lines
123 struct buffer dev_table_buf;123 struct buffer dev_table_buf;
124 char srcversion[25];124 char srcversion[25];
125 // Missing namespace dependencies125 // Missing namespace dependencies
126 struct namespace_list *missing_namespaces;126 struct list_head missing_namespaces;
127 // Actual imported namespaces127 // Actual imported namespaces
128 struct namespace_list *imported_namespaces;128 struct list_head imported_namespaces;
129 char name[];129 char name[];
130};130};
131 131

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t