diff mbox series

[1/3] modpost: refactor seen flag clearing in add_depends()

Message ID 1542959843-16145-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit d2665ca8e3310d045b62397590ab54dc485e035e
Headers show
Series [1/3] modpost: refactor seen flag clearing in add_depends() | expand

Commit Message

Masahiro Yamada Nov. 23, 2018, 7:57 a.m. UTC
You do not need to iterate over all modules for resetting ->seen flag
because add_depends() is only interested in modules that export symbols
referenced from the given 'mod'.

This also avoids shadowing the 'modules' parameter of add_depends().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 scripts/mod/modpost.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.7.4

Comments

Masahiro Yamada Dec. 1, 2018, 2:54 p.m. UTC | #1
On Sat, Nov 24, 2018 at 5:08 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>

> You do not need to iterate over all modules for resetting ->seen flag

> because add_depends() is only interested in modules that export symbols

> referenced from the given 'mod'.

>

> This also avoids shadowing the 'modules' parameter of add_depends().

>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---



Applied to linux-kbuild.



>  scripts/mod/modpost.c | 12 ++++++------

>  1 file changed, 6 insertions(+), 6 deletions(-)

>

> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c

> index c64066d..39432c2 100644

> --- a/scripts/mod/modpost.c

> +++ b/scripts/mod/modpost.c

> @@ -2229,15 +2229,15 @@ static int add_versions(struct buffer *b, struct module *mod)

>         return err;

>  }

>

> -static void add_depends(struct buffer *b, struct module *mod,

> -                       struct module *modules)

> +static void add_depends(struct buffer *b, struct module *mod)

>  {

>         struct symbol *s;

> -       struct module *m;

>         int first = 1;

>

> -       for (m = modules; m; m = m->next)

> -               m->seen = is_vmlinux(m->name);

> +       /* Clear ->seen flag of modules that own symbols needed by this. */

> +       for (s = mod->unres; s; s = s->next)

> +               if (s->module)

> +                       s->module->seen = is_vmlinux(s->module->name);

>

>         buf_printf(b, "\n");

>         buf_printf(b, "static const char __module_depends[]\n");

> @@ -2506,7 +2506,7 @@ int main(int argc, char **argv)

>                 add_retpoline(&buf);

>                 add_staging_flag(&buf, mod->name);

>                 err |= add_versions(&buf, mod);

> -               add_depends(&buf, mod, modules);

> +               add_depends(&buf, mod);

>                 add_moddevtable(&buf, mod);

>                 add_srcversion(&buf, mod);

>

> --

> 2.7.4

>



-- 
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index c64066d..39432c2 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2229,15 +2229,15 @@  static int add_versions(struct buffer *b, struct module *mod)
 	return err;
 }
 
-static void add_depends(struct buffer *b, struct module *mod,
-			struct module *modules)
+static void add_depends(struct buffer *b, struct module *mod)
 {
 	struct symbol *s;
-	struct module *m;
 	int first = 1;
 
-	for (m = modules; m; m = m->next)
-		m->seen = is_vmlinux(m->name);
+	/* Clear ->seen flag of modules that own symbols needed by this. */
+	for (s = mod->unres; s; s = s->next)
+		if (s->module)
+			s->module->seen = is_vmlinux(s->module->name);
 
 	buf_printf(b, "\n");
 	buf_printf(b, "static const char __module_depends[]\n");
@@ -2506,7 +2506,7 @@  int main(int argc, char **argv)
 		add_retpoline(&buf);
 		add_staging_flag(&buf, mod->name);
 		err |= add_versions(&buf, mod);
-		add_depends(&buf, mod, modules);
+		add_depends(&buf, mod);
 		add_moddevtable(&buf, mod);
 		add_srcversion(&buf, mod);