aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2020-02-11 18:04:15 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-02-13 18:32:38 +0100
commitb50ae26fec7d566fe867851c46fc89bc622fa11b (patch)
tree3d54eca04efa5319120536e4826d0b2a49fefb8f
parent6d779f4925fda304181ec3f09b9135d35ed9b5a2 (diff)
downloadsparse-b50ae26fec7d566fe867851c46fc89bc622fa11b.tar.gz
dissect: move __sparse() callsite from test-dissect.c to dissect.c
This is more flexible. For example, we can change dissect() to inspect file_scope->symbols too without changing its callers. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--dissect.c5
-rw-r--r--dissect.h2
-rw-r--r--test-dissect.c11
3 files changed, 6 insertions, 12 deletions
diff --git a/dissect.c b/dissect.c
index 823a3489..499e0a0e 100644
--- a/dissect.c
+++ b/dissect.c
@@ -642,8 +642,9 @@ static void do_sym_list(struct symbol_list *list)
DO_LIST(list, sym, do_symbol(sym));
}
-void dissect(struct symbol_list *list, struct reporter *rep)
+void dissect(struct reporter *rep, struct string_list *filelist)
{
reporter = rep;
- do_sym_list(list);
+
+ DO_LIST(filelist, file, do_sym_list(__sparse(file)));
}
diff --git a/dissect.h b/dissect.h
index 178dba5d..326d3dc3 100644
--- a/dissect.h
+++ b/dissect.h
@@ -32,6 +32,6 @@ static inline bool sym_is_local(struct symbol *sym)
return sym->kind == 'v' && !(sym->ctype.modifiers & MOD_TOPLEVEL);
}
-extern void dissect(struct symbol_list *, struct reporter *);
+extern void dissect(struct reporter *, struct string_list *);
#endif
diff --git a/test-dissect.c b/test-dissect.c
index c4b454c6..4b2d3bea 100644
--- a/test-dissect.c
+++ b/test-dissect.c
@@ -1,7 +1,5 @@
#include "dissect.h"
-static unsigned dotc_stream;
-
static inline const char *show_mode(unsigned mode)
{
static char str[3];
@@ -119,15 +117,10 @@ int main(int argc, char **argv)
.r_symbol = r_symbol,
.r_member = r_member,
};
- struct string_list *filelist = NULL;
- char *file;
+ struct string_list *filelist = NULL;
sparse_initialize(argc, argv, &filelist);
-
- FOR_EACH_PTR(filelist, file) {
- dotc_stream = input_stream_nr;
- dissect(__sparse(file), &reporter);
- } END_FOR_EACH_PTR(file);
+ dissect(&reporter, filelist);
return 0;
}