[PATCH 18/27] modpost: make sym_add_exported() a void function

From: Masahiro Yamada
Date: Sun Apr 24 2022 - 15:10:46 EST


Currently, sym_add_exported() returns the pointer to the added symbol
just for doing:

s->is_static = false;

in the read_dump() function.

I noticed it was unneeded because sym_add_exported() can know the proper
default for the 'is_static' member by checking mod->from_dump.

This makes the code slightly simpler.

Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
---

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

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 4f0b2b23516a..fd710aa59bda 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -243,7 +243,7 @@ static struct symbol *alloc_symbol(const char *name, struct symbol *next)
memset(s, 0, sizeof(*s));
strcpy(s->name, name);
s->next = next;
- s->is_static = true;
+
return s;
}

@@ -401,8 +401,8 @@ static void sym_update_namespace(const char *symname, const char *namespace)
s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
}

-static struct symbol *sym_add_exported(const char *name, struct module *mod,
- enum export export)
+static void sym_add_exported(const char *name, struct module *mod,
+ enum export export)
{
struct symbol *s = find_symbol(name);

@@ -414,9 +414,9 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,

s = new_symbol(name, mod, export);
s->module = mod;
+ s->is_static = !mod->from_dump;
s->export = export;
list_add_tail(&s->list, &mod->exported_symbols);
- return s;
}

static void sym_set_crc(const char *name, unsigned int crc)
@@ -2419,7 +2419,6 @@ static void read_dump(const char *fname)
char *symname, *namespace, *modname, *d, *export;
unsigned int crc;
struct module *mod;
- struct symbol *s;

if (!(symname = strchr(line, '\t')))
goto fail;
@@ -2442,8 +2441,7 @@ static void read_dump(const char *fname)
mod = new_module(modname);
mod->from_dump = true;
}
- s = sym_add_exported(symname, mod, export_no(export));
- s->is_static = false;
+ sym_add_exported(symname, mod, export_no(export));
sym_set_crc(symname, crc);
sym_update_namespace(symname, namespace);
}
--
2.32.0