History

modpost: replace tdb_hash() with hash_str()

Use a helper available in scripts/include/hash.h.

Masahiro Yamada committed 1 year ago

Commit 5eaea851 parent 6b1fabc1 file · +3 −15Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/mod/modpost.c+3−15
@@ -21,6 +21,7 @@ · 20 unmodified lines
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 { · 183 unmodified lines
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) · 11 unmodified lines
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) · 14 unmodified lines
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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t