mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
modpost: split new_symbol() to symbol allocation and hash table addition
new_symbol() does two things; allocate a new symbol and register it to the hash table. Using a separate function for each is easier to understand. Replace new_symbol() with hash_add_symbol(). Remove the second parameter of alloc_symbol(). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
This commit is contained in:
@@ -242,34 +242,31 @@ static inline unsigned int tdb_hash(const char *name)
|
|||||||
* Allocate a new symbols for use in the hash of exported symbols or
|
* Allocate a new symbols for use in the hash of exported symbols or
|
||||||
* the list of unresolved symbols per module
|
* the list of unresolved symbols per module
|
||||||
**/
|
**/
|
||||||
static struct symbol *alloc_symbol(const char *name, struct symbol *next)
|
static struct symbol *alloc_symbol(const char *name)
|
||||||
{
|
{
|
||||||
struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
|
struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
|
||||||
|
|
||||||
memset(s, 0, sizeof(*s));
|
memset(s, 0, sizeof(*s));
|
||||||
strcpy(s->name, name);
|
strcpy(s->name, name);
|
||||||
s->next = next;
|
|
||||||
s->is_static = true;
|
s->is_static = true;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For the hash of exported symbols */
|
/* For the hash of exported symbols */
|
||||||
static struct symbol *new_symbol(const char *name, struct module *module,
|
static void hash_add_symbol(struct symbol *sym)
|
||||||
enum export export)
|
|
||||||
{
|
{
|
||||||
unsigned int hash;
|
unsigned int hash;
|
||||||
|
|
||||||
hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
|
hash = tdb_hash(sym->name) % SYMBOL_HASH_SIZE;
|
||||||
symbolhash[hash] = alloc_symbol(name, symbolhash[hash]);
|
sym->next = symbolhash[hash];
|
||||||
|
symbolhash[hash] = sym;
|
||||||
return symbolhash[hash];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
|
static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
|
||||||
{
|
{
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
|
|
||||||
sym = alloc_symbol(name, NULL);
|
sym = alloc_symbol(name);
|
||||||
sym->weak = weak;
|
sym->weak = weak;
|
||||||
|
|
||||||
list_add_tail(&sym->list, &mod->unresolved_symbols);
|
list_add_tail(&sym->list, &mod->unresolved_symbols);
|
||||||
@@ -418,10 +415,11 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
|
|||||||
s->module->is_vmlinux ? "" : ".ko");
|
s->module->is_vmlinux ? "" : ".ko");
|
||||||
}
|
}
|
||||||
|
|
||||||
s = new_symbol(name, mod, export);
|
s = alloc_symbol(name);
|
||||||
s->module = mod;
|
s->module = mod;
|
||||||
s->export = export;
|
s->export = export;
|
||||||
list_add_tail(&s->list, &mod->exported_symbols);
|
list_add_tail(&s->list, &mod->exported_symbols);
|
||||||
|
hash_add_symbol(s);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user