Skip to contentSkip to conversation

dissect: move __sparse() callsite from test-dissect.c to dissect.c

PATCH New Oleg Nesterov 1 participant 1 message Feb 11, 2020 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 dissect.c      |  5 +++--
 dissect.h      |  2 +-
 test-dissect.c | 11 ++---------
 3 files changed, 6 insertions(+), 12 deletions(-)
dissect.c +3 -2
index 823a348..499e0a0 100644
@@ -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)));
 }
dissect.h +1 -1
index 178dba5..326d3dc 100644
@@ -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
test-dissect.c +1 -4
index c4b454c..4b2d3be 100644
@@ -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);