From 7dcdec7722f35e94e815091a5b3465261b9940d8 Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 18 Apr 2021 09:20:43 +0000 Subject: [PATCH] lint: do not modify curr_pos in check_global_symbols No functional change. --- usr.bin/xlint/lint1/decl.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index 99419dba7518..eb98cf3e184e 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.175 2021/04/18 09:15:16 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.176 2021/04/18 09:20:43 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.175 2021/04/18 09:15:16 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.176 2021/04/18 09:20:43 rillig Exp $"); #endif #include @@ -3172,13 +3172,10 @@ void check_global_symbols(void) { sym_t *sym; - pos_t cpos; if (block_level != 0 || dcs->d_next != NULL) norecover(); - cpos = curr_pos; - for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) { if (sym->s_block_level == -1) continue; @@ -3190,29 +3187,26 @@ check_global_symbols(void) lint_assert(sym->s_kind == FMEMBER); } } - - curr_pos = cpos; } static void check_unused_static_global_variable(const sym_t *sym) { - curr_pos = sym->s_def_pos; if (sym->s_type->t_tspec == FUNC) { if (sym->s_def == DEF) { if (!sym->s_inline) /* static function %s unused */ - warning(236, sym->s_name); + warning_at(236, sym->s_def_pos, sym->s_name); } else { /* static function %s declared but not defined */ - warning(290, sym->s_name); + warning_at(290, sym->s_def_pos, sym->s_name); } } else if (!sym->s_set) { /* static variable %s unused */ - warning(226, sym->s_name); + warning_at(226, sym->s_def_pos, sym->s_name); } else { /* static variable %s set but not used */ - warning(307, sym->s_name); + warning_at(307, sym->s_def_pos, sym->s_name); } } @@ -3220,18 +3214,16 @@ static void check_static_global_variable(const sym_t *sym) { if (sym->s_type->t_tspec == FUNC && sym->s_used && sym->s_def != DEF) { - curr_pos = sym->s_use_pos; /* static function called but not defined: %s() */ - error(225, sym->s_name); + error_at(225, sym->s_use_pos, sym->s_name); } if (!sym->s_used) check_unused_static_global_variable(sym); if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) { - curr_pos = sym->s_def_pos; /* const object %s should have initializer */ - warning(227, sym->s_name); + warning_at(227, sym->s_def_pos, sym->s_name); } }