Skip to content

Commit 5eaea85

Browse files
committed
modpost: replace tdb_hash() with hash_str()
Use a helper available in scripts/include/hash.h. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 6b1fabc commit 5eaea85

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

scripts/mod/modpost.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <stdbool.h>
2222
#include <errno.h>
2323

24+
#include <hash.h>
2425
#include <hashtable.h>
2526
#include <list.h>
2627
#include <xalloc.h>
@@ -210,19 +211,6 @@ struct symbol {
210211

211212
static HASHTABLE_DEFINE(symbol_hashtable, 1U << 10);
212213

213-
/* This is based on the hash algorithm from gdbm, via tdb */
214-
static inline unsigned int tdb_hash(const char *name)
215-
{
216-
unsigned value; /* Used to compute the hash value. */
217-
unsigned i; /* Used to cycle through random values. */
218-
219-
/* Set the initial value from the key size. */
220-
for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++)
221-
value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
222-
223-
return (1103515243 * value + 12345);
224-
}
225-
226214
/**
227215
* Allocate a new symbols for use in the hash of exported symbols or
228216
* the list of unresolved symbols per module
@@ -240,7 +228,7 @@ static struct symbol *alloc_symbol(const char *name)
240228
/* For the hash of exported symbols */
241229
static void hash_add_symbol(struct symbol *sym)
242230
{
243-
hash_add(symbol_hashtable, &sym->hnode, tdb_hash(sym->name));
231+
hash_add(symbol_hashtable, &sym->hnode, hash_str(sym->name));
244232
}
245233

246234
static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
@@ -261,7 +249,7 @@ static struct symbol *sym_find_with_module(const char *name, struct module *mod)
261249
if (name[0] == '.')
262250
name++;
263251

264-
hash_for_each_possible(symbol_hashtable, s, hnode, tdb_hash(name)) {
252+
hash_for_each_possible(symbol_hashtable, s, hnode, hash_str(name)) {
265253
if (strcmp(s->name, name) == 0 && (!mod || s->module == mod))
266254
return s;
267255
}

0 commit comments

Comments
 (0)