History

modpost: use doubly linked list for dump_lists

This looks easier to understand (just because this is a pattern in the kernel code). No functional change is intended.

Masahiro Yamada committed 4 years ago

Commit 44840541 parent 8a691521 file · +10 −14Browse files

Unified · Split

scripts/mod/modpost.c+10−14
@@ -2505,7 +2505,7 @@ static void write_namespace_deps_files(const char *fname) · 2504 unmodified lines
2505}2505}
2506 2506
2507struct dump_list {2507struct dump_list {
2508 struct dump_list *next;2508 struct list_head list;
2509 const char *file;2509 const char *file;
2510};2510};
2511 2511
@@ -2517,8 +2517,8 @@ int main(int argc, char **argv) · 5 unmodified lines
2517 char *dump_write = NULL, *files_source = NULL;2517 char *dump_write = NULL, *files_source = NULL;
2518 int opt;2518 int opt;
2519 int n;2519 int n;
2520 struct dump_list *dump_read_start = NULL;2520 LIST_HEAD(dump_lists);
2521 struct dump_list **dump_read_iter = &dump_read_start;2521 struct dump_list *dl, *dl2;
2522 2522
2523 while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {2523 while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {
2524 switch (opt) {2524 switch (opt) {
@@ -2526,10 +2526,9 @@ int main(int argc, char **argv) · 1 unmodified line
2526 external_module = true;2526 external_module = true;
2527 break;2527 break;
2528 case 'i':2528 case 'i':
2529 *dump_read_iter =2529 dl = NOFAIL(malloc(sizeof(*dl)));
2530 NOFAIL(calloc(1, sizeof(**dump_read_iter)));2530 dl->file = optarg;
2531 (*dump_read_iter)->file = optarg;2531 list_add_tail(&dl->list, &dump_lists);
2532 dump_read_iter = &(*dump_read_iter)->next;
2533 break;2532 break;
2534 case 'm':2533 case 'm':
2535 modversions = true;2534 modversions = true;
@@ -2563,13 +2562,10 @@ int main(int argc, char **argv) · 27 unmodified lines
2563 }2562 }
2564 }2563 }
2565 2564
2566 while (dump_read_start) {2565 list_for_each_entry_safe(dl, dl2, &dump_lists, list) {
2567 struct dump_list *tmp;2566 read_dump(dl->file);
2568 2567 list_del(&dl->list);
2569 read_dump(dump_read_start->file);2568 free(dl);
2570 tmp = dump_read_start->next;
2571 free(dump_read_start);
2572 dump_read_start = tmp;
2573 }2569 }
2574 2570
2575 while (optind < argc)2571 while (optind < argc)

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