Commit 01762c4ec5f6f62c550304b9c70e824293cefdd0
1 parent
68eb8563a1
Exists in
master
and in
20 other branches
genksyms: simplify usage of find_symbol()
Allow searching for symbols of an exact type. The lexer does this and a subsequent patch will add one more usage. Signed-off-by: Michal Marek <mmarek@suse.cz> Acked-by: Sam Ravnborg <sam@ravnborg.org>
Showing 4 changed files with 9 additions and 9 deletions Side-by-side Diff
scripts/genksyms/genksyms.c
... | ... | @@ -156,7 +156,7 @@ |
156 | 156 | return t; |
157 | 157 | } |
158 | 158 | |
159 | -struct symbol *find_symbol(const char *name, enum symbol_type ns) | |
159 | +struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact) | |
160 | 160 | { |
161 | 161 | unsigned long h = crc32(name) % HASH_BUCKETS; |
162 | 162 | struct symbol *sym; |
... | ... | @@ -167,6 +167,8 @@ |
167 | 167 | sym->is_declared) |
168 | 168 | break; |
169 | 169 | |
170 | + if (exact && sym && sym->type != ns) | |
171 | + return NULL; | |
170 | 172 | return sym; |
171 | 173 | } |
172 | 174 | |
... | ... | @@ -511,7 +513,7 @@ |
511 | 513 | break; |
512 | 514 | |
513 | 515 | case SYM_TYPEDEF: |
514 | - subsym = find_symbol(cur->string, cur->tag); | |
516 | + subsym = find_symbol(cur->string, cur->tag, 0); | |
515 | 517 | /* FIXME: Bad reference files can segfault here. */ |
516 | 518 | if (subsym->expansion_trail) { |
517 | 519 | if (flag_dump_defs) |
... | ... | @@ -528,7 +530,7 @@ |
528 | 530 | case SYM_STRUCT: |
529 | 531 | case SYM_UNION: |
530 | 532 | case SYM_ENUM: |
531 | - subsym = find_symbol(cur->string, cur->tag); | |
533 | + subsym = find_symbol(cur->string, cur->tag, 0); | |
532 | 534 | if (!subsym) { |
533 | 535 | struct string_list *n; |
534 | 536 | |
... | ... | @@ -582,7 +584,7 @@ |
582 | 584 | { |
583 | 585 | struct symbol *sym; |
584 | 586 | |
585 | - sym = find_symbol(name, SYM_NORMAL); | |
587 | + sym = find_symbol(name, SYM_NORMAL, 0); | |
586 | 588 | if (!sym) |
587 | 589 | error_with_pos("export undefined symbol %s", name); |
588 | 590 | else { |
scripts/genksyms/genksyms.h
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 | extern int cur_line; |
59 | 59 | extern char *cur_filename; |
60 | 60 | |
61 | -struct symbol *find_symbol(const char *name, enum symbol_type ns); | |
61 | +struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact); | |
62 | 62 | struct symbol *add_symbol(const char *name, enum symbol_type type, |
63 | 63 | struct string_list *defn, int is_extern); |
64 | 64 | void export_symbol(const char *); |
scripts/genksyms/lex.c_shipped
scripts/genksyms/lex.l