Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+8 -10
+8 -10
scripts/mod/modpost.c
··· 242 242 * Allocate a new symbols for use in the hash of exported symbols or 243 243 * the list of unresolved symbols per module 244 244 **/ 245 - static struct symbol *alloc_symbol(const char *name, struct symbol *next) 245 + static struct symbol *alloc_symbol(const char *name) 246 246 { 247 247 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); 248 248 249 249 memset(s, 0, sizeof(*s)); 250 250 strcpy(s->name, name); 251 - s->next = next; 252 251 s->is_static = true; 253 252 return s; 254 253 } 255 254 256 255 /* For the hash of exported symbols */ 257 - static struct symbol *new_symbol(const char *name, struct module *module, 258 - enum export export) 256 + static void hash_add_symbol(struct symbol *sym) 259 257 { 260 258 unsigned int hash; 261 259 262 - hash = tdb_hash(name) % SYMBOL_HASH_SIZE; 263 - symbolhash[hash] = alloc_symbol(name, symbolhash[hash]); 264 - 265 - return symbolhash[hash]; 260 + hash = tdb_hash(sym->name) % SYMBOL_HASH_SIZE; 261 + sym->next = symbolhash[hash]; 262 + symbolhash[hash] = sym; 266 263 } 267 264 268 265 static void sym_add_unresolved(const char *name, struct module *mod, bool weak) 269 266 { 270 267 struct symbol *sym; 271 268 272 - sym = alloc_symbol(name, NULL); 269 + sym = alloc_symbol(name); 273 270 sym->weak = weak; 274 271 275 272 list_add_tail(&sym->list, &mod->unresolved_symbols); ··· 415 418 s->module->is_vmlinux ? "" : ".ko"); 416 419 } 417 420 418 - s = new_symbol(name, mod, export); 421 + s = alloc_symbol(name); 419 422 s->module = mod; 420 423 s->export = export; 421 424 list_add_tail(&s->list, &mod->exported_symbols); 425 + hash_add_symbol(s); 422 426 423 427 return s; 424 428 }