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

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

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