Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: clean up initstack_pop_item_named_...
details: https://anonhg.NetBSD.org/src/rev/6fa7c061a981
branches: trunk
changeset: 1019987:6fa7c061a981
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Mar 27 16:24:21 2021 +0000
description:
lint: clean up initstack_pop_item_named_member
Previously, the code accessed the global variable for the designator
several times, even though the designator cannot change during this part
of the code. Make this obvious by passing this designator as a
parameter instead.
No functional change.
diffstat:
usr.bin/xlint/lint1/init.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diffs (77 lines):
diff -r 821f6c36febc -r 6fa7c061a981 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sat Mar 27 16:13:41 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sat Mar 27 16:24:21 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.136 2021/03/27 13:17:42 rillig Exp $ */
+/* $NetBSD: init.c,v 1.137 2021/03/27 16:24:21 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.136 2021/03/27 13:17:42 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.137 2021/03/27 16:24:21 rillig Exp $");
#endif
#include <stdlib.h>
@@ -598,7 +598,7 @@
/* TODO: document me */
static void
-initstack_pop_item_named_member(void)
+initstack_pop_item_named_member(const char *name)
{
initstack_element *istk = initstk_lvalue;
sym_t *m;
@@ -607,8 +607,7 @@
* TODO: fix wording of the debug message; this doesn't seem to be
* related to initializing the named member.
*/
- debug_step("initializing named member '%s'",
- current_designation().head->name);
+ debug_step("initializing named member '%s'", name);
if (istk->i_type->t_tspec != STRUCT &&
istk->i_type->t_tspec != UNION) {
@@ -624,7 +623,7 @@
if (m->s_bitfield && m->s_name == unnamed)
continue;
- if (strcmp(m->s_name, current_designation().head->name) == 0) {
+ if (strcmp(m->s_name, name) == 0) {
debug_step("found matching member");
istk->i_subt = m->s_type;
/* XXX: why ++? */
@@ -635,8 +634,9 @@
}
}
+ /* TODO: add type information to the message */
/* undefined struct/union member: %s */
- error(101, current_designation().head->name);
+ error(101, name);
designation_shift_level();
istk->i_seen_named_member = true;
@@ -672,6 +672,7 @@
initstack_pop_item(void)
{
initstack_element *istk;
+ designator *first_designator;
debug_enter();
@@ -689,8 +690,9 @@
lint_assert(istk->i_remaining >= 0);
debug_step("%d elements remaining", istk->i_remaining);
- if (current_designation().head != NULL)
- initstack_pop_item_named_member();
+ first_designator = current_designation().head;
+ if (first_designator != NULL && first_designator->name != NULL)
+ initstack_pop_item_named_member(first_designator->name);
else
initstack_pop_item_unnamed();
Home |
Main Index |
Thread Index |
Old Index