History

modpost: refactor seen flag clearing in add_depends()

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().

Masahiro Yamada committed 7 years ago

Commit d2665ca1 parent f880eea1 file · +6 −6Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/mod/modpost.c+6−6
@@ -2241,15 +2241,15 @@ static int add_versions(struct buffer *b, struct module *mod) · 2240 unmodified lines
22412241 return err;
22422242 }
22432243
2244−static void add_depends(struct buffer *b, struct module *mod,
2245− struct module *modules)
2244+static void add_depends(struct buffer *b, struct module *mod)
22462245 {
22472246 struct symbol *s;
2248− struct module *m;
22492247 int first = 1;
22502248
2251− for (m = modules; m; m = m->next)
2252− m->seen = is_vmlinux(m->name);
2249+ /* Clear ->seen flag of modules that own symbols needed by this. */
2250+ for (s = mod->unres; s; s = s->next)
2251+ if (s->module)
2252+ s->module->seen = is_vmlinux(s->module->name);
22532253
22542254 buf_printf(b, "\n");
22552255 buf_printf(b, "static const char __module_depends[]\n");
@@ -2518,7 +2518,7 @@ int main(int argc, char **argv) · 262 unmodified lines
25182518 add_retpoline(&buf);
25192519 add_staging_flag(&buf, mod->name);
25202520 err |= add_versions(&buf, mod);
2521− add_depends(&buf, mod, modules);
2521+ add_depends(&buf, mod);
25222522 add_moddevtable(&buf, mod);
25232523 add_srcversion(&buf, mod);
25242524