Skip to content

Commit 3b41528

Browse files
committed
modpost: move unresolved symbol checks to check_exports()
This will fit better in check_exports() than add_versions(). Signed-off-by: Masahiro Yamada <[email protected]>
1 parent c6826ad commit 3b41528

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

scripts/mod/modpost.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,15 +2097,27 @@ static void check_for_unused(enum export exp, const char *m, const char *s)
20972097
}
20982098
}
20992099

2100-
static void check_exports(struct module *mod)
2100+
static int check_exports(struct module *mod)
21012101
{
21022102
struct symbol *s, *exp;
2103+
int err = 0;
21032104

21042105
for (s = mod->unres; s; s = s->next) {
21052106
const char *basename;
21062107
exp = find_symbol(s->name);
2107-
if (!exp || exp->module == mod)
2108+
if (!exp || exp->module == mod) {
2109+
if (have_vmlinux && !s->weak) {
2110+
if (warn_unresolved) {
2111+
warn("\"%s\" [%s.ko] undefined!\n",
2112+
s->name, mod->name);
2113+
} else {
2114+
merror("\"%s\" [%s.ko] undefined!\n",
2115+
s->name, mod->name);
2116+
err = 1;
2117+
}
2118+
}
21082119
continue;
2120+
}
21092121
basename = strrchr(mod->name, '/');
21102122
if (basename)
21112123
basename++;
@@ -2115,6 +2127,8 @@ static void check_exports(struct module *mod)
21152127
check_for_gpl_usage(exp->export, basename, exp->name);
21162128
check_for_unused(exp->export, basename, exp->name);
21172129
}
2130+
2131+
return err;
21182132
}
21192133

21202134
static int check_modname_len(struct module *mod)
@@ -2192,19 +2206,8 @@ static int add_versions(struct buffer *b, struct module *mod)
21922206

21932207
for (s = mod->unres; s; s = s->next) {
21942208
exp = find_symbol(s->name);
2195-
if (!exp || exp->module == mod) {
2196-
if (have_vmlinux && !s->weak) {
2197-
if (warn_unresolved) {
2198-
warn("\"%s\" [%s.ko] undefined!\n",
2199-
s->name, mod->name);
2200-
} else {
2201-
merror("\"%s\" [%s.ko] undefined!\n",
2202-
s->name, mod->name);
2203-
err = 1;
2204-
}
2205-
}
2209+
if (!exp || exp->module == mod)
22062210
continue;
2207-
}
22082211
s->module = exp->module;
22092212
s->crc_valid = exp->crc_valid;
22102213
s->crc = exp->crc;
@@ -2507,7 +2510,7 @@ int main(int argc, char **argv)
25072510
buf.pos = 0;
25082511

25092512
err |= check_modname_len(mod);
2510-
check_exports(mod);
2513+
err |= check_exports(mod);
25112514
add_header(&buf, mod);
25122515
add_intree_flag(&buf, !external_module);
25132516
add_retpoline(&buf);

0 commit comments

Comments
 (0)