This looks easier to understand (just because this is a pattern in the kernel code). No functional change is intended.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -2505,7 +2505,7 @@ static void write_namespace_deps_files(const char *fname) · 2504 unmodified lines | ||
| 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,8 +2517,8 @@ int main(int argc, char **argv) · 5 unmodified lines | ||
| 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,10 +2526,9 @@ int main(int argc, char **argv) · 1 unmodified line | ||
| 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; |
| @@ -2563,13 +2562,10 @@ int main(int argc, char **argv) · 27 unmodified lines | ||
| 2563 | 2562 | } |
| 2564 | 2563 | } |
| 2565 | 2564 | |
| 2566 | − while (dump_read_start) { | |
| 2567 | − struct dump_list *tmp; | |
| 2568 | − | |
| 2569 | − read_dump(dump_read_start->file); | |
| 2570 | − tmp = dump_read_start->next; | |
| 2571 | − free(dump_read_start); | |
| 2572 | − dump_read_start = tmp; | |
| 2565 | + list_for_each_entry_safe(dl, dl2, &dump_lists, list) { | |
| 2566 | + read_dump(dl->file); | |
| 2567 | + list_del(&dl->list); | |
| 2568 | + free(dl); | |
| 2573 | 2569 | } |
| 2574 | 2570 | |
| 2575 | 2571 | while (optind < argc) |