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: 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>

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