[PATCH] sparse/dissect: change do_file() to use __sparse()

Oleg Nesterov <[email protected]> Sun, 28 Dec 2025 13:55:15 +0100
Newsgroups org.kernel.vger.linux-sparse
Message-ID <[email protected]>
rather than do sparse_keep_tokens/clear_token_alloc by hand.

dissect/semind doesn't need/use tokens, we can safely do
drop_all_allocations(token_allocator) after parsing.

Signed-off-by: Oleg Nesterov <[email protected]>
---
 dissect.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/dissect.c b/dissect.c
index 62f927c5..55e76846 100644
--- a/dissect.c
+++ b/dissect.c
@@ -681,14 +681,10 @@ static inline bool valid_namespace(enum namespace ns)
 	return (ns == NS_TYPEDEF || ns == NS_MACRO || ns == NS_UNDEF || ns == NS_STRUCT || ns == NS_SYMBOL);
 }
 
-static void do_file(char *file)
+static void do_file(struct symbol_list *res)
 {
-	struct symbol_list *res = sparse_keep_tokens(file);
-
-	if (!dissect_show_all_symbols) {
-		do_sym_list(res);
-		goto end;
-	}
+	if (!dissect_show_all_symbols)
+		return do_sym_list(res);
 
 	DO_LIST(file_scope->symbols, sym,
 		if (input_streams[sym->pos.stream].fd != -1 && valid_namespace(sym->namespace)) {
@@ -719,10 +715,6 @@ static void do_file(char *file)
 			do_symbol(sym);
 		}
 	);
-
-end:
-	/* Drop the tokens for this file after parsing */
-	clear_token_alloc();
 }
 
 void dissect(struct reporter *rep, struct string_list *filelist)
@@ -730,5 +722,5 @@ void dissect(struct reporter *rep, struct string_list *filelist)
 	dissect_mode = 1;
 	reporter = rep;
 
-	DO_LIST(filelist, file, do_file(file));
+	DO_LIST(filelist, file, do_file(__sparse(file)));
 }
-- 
2.52.0