modpost: load KBUILD_EXTRA_SYMBOLS files in order
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 1 Jun 2020 05:57:04 +0000 (14:57 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 3 Jun 2020 04:22:18 +0000 (13:22 +0900)
Currently, modpost reads extra symbol dump files in the reverse order.
If '-e foo -e bar' is given, modpost reads bar, foo, in this order.

This is probably not a big deal, but there is no good reason to reverse
the order. Read files in the given order.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/mod/modpost.c

index 1601395..5224a02 100644 (file)
@@ -2555,8 +2555,8 @@ int main(int argc, char **argv)
        int opt;
        int err;
        int n;
-       struct ext_sym_list *extsym_iter;
        struct ext_sym_list *extsym_start = NULL;
+       struct ext_sym_list **extsym_iter = &extsym_start;
 
        while ((opt = getopt(argc, argv, "i:e:mnsT:o:awENd:")) != -1) {
                switch (opt) {
@@ -2566,11 +2566,9 @@ int main(int argc, char **argv)
                        break;
                case 'e':
                        external_module = 1;
-                       extsym_iter =
-                          NOFAIL(malloc(sizeof(*extsym_iter)));
-                       extsym_iter->next = extsym_start;
-                       extsym_iter->file = optarg;
-                       extsym_start = extsym_iter;
+                       *extsym_iter = NOFAIL(calloc(1, sizeof(**extsym_iter)));
+                       (*extsym_iter)->file = optarg;
+                       extsym_iter = &(*extsym_iter)->next;
                        break;
                case 'm':
                        modversions = 1;
@@ -2610,10 +2608,12 @@ int main(int argc, char **argv)
        if (kernel_read)
                read_dump(kernel_read, 1);
        while (extsym_start) {
+               struct ext_sym_list *tmp;
+
                read_dump(extsym_start->file, 0);
-               extsym_iter = extsym_start->next;
+               tmp = extsym_start->next;
                free(extsym_start);
-               extsym_start = extsym_iter;
+               extsym_start = tmp;
        }
 
        while (optind < argc)