Module Name: src
Committed By: rillig
Date: Fri Mar 19 00:19:32 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: init.c
Log Message:
lint: split initstack_pop_item into separate functions
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/xlint/lint1/init.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.100 src/usr.bin/xlint/lint1/init.c:1.101
--- src/usr.bin/xlint/lint1/init.c:1.100 Fri Mar 19 00:08:13 2021
+++ src/usr.bin/xlint/lint1/init.c Fri Mar 19 00:19:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.100 2021/03/19 00:08:13 rillig Exp $ */
+/* $NetBSD: init.c,v 1.101 2021/03/19 00:19:32 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.100 2021/03/19 00:08:13 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.101 2021/03/19 00:19:32 rillig Exp $");
#endif
#include <stdlib.h>
@@ -410,59 +410,44 @@ initstack_init(void)
}
static void
-initstack_pop_item(void)
+initstack_pop_item_named_member(void)
{
- initstack_element *istk;
- sym_t *m;
-
- debug_enter();
-
- istk = initstk;
- debug_step("popping:");
- debug_initstack_element(istk);
-
- initstk = istk->i_enclosing;
- free(istk);
- istk = initstk;
- lint_assert(istk != NULL);
-
- istk->i_remaining--;
- lint_assert(istk->i_remaining >= 0);
- debug_step("%d elements remaining", istk->i_remaining);
+ initstack_element *istk = initstk;
+ sym_t *m;
- if (namedmem != NULL) {
- debug_step("initializing named member '%s'", namedmem->n_name);
+ debug_step("initializing named member '%s'", namedmem->n_name);
- lint_assert(istk->i_type->t_tspec == STRUCT ||
- istk->i_type->t_tspec == UNION);
- for (m = istk->i_type->t_str->sou_first_member;
- m != NULL; m = m->s_next) {
+ lint_assert(istk->i_type->t_tspec == STRUCT ||
+ istk->i_type->t_tspec == UNION);
+ for (m = istk->i_type->t_str->sou_first_member;
+ m != NULL; m = m->s_next) {
- if (m->s_bitfield && m->s_name == unnamed)
- continue;
+ if (m->s_bitfield && m->s_name == unnamed)
+ continue;
- if (strcmp(m->s_name, namedmem->n_name) == 0) {
- debug_step("found matching member");
- istk->i_subt = m->s_type;
- /* XXX: why ++? */
- istk->i_remaining++;
- /* XXX: why is i_seen_named_member not set? */
- pop_member();
- debug_initstack();
- debug_leave();
- return;
- }
+ if (strcmp(m->s_name, namedmem->n_name) == 0) {
+ debug_step("found matching member");
+ istk->i_subt = m->s_type;
+ /* XXX: why ++? */
+ istk->i_remaining++;
+ /* XXX: why is i_seen_named_member not set? */
+ pop_member();
+ return;
}
+ }
- /* undefined struct/union member: %s */
- error(101, namedmem->n_name);
+ /* undefined struct/union member: %s */
+ error(101, namedmem->n_name);
- pop_member();
- istk->i_seen_named_member = true;
- debug_initstack();
- debug_leave();
- return;
- }
+ pop_member();
+ istk->i_seen_named_member = true;
+}
+
+static void
+initstack_pop_item_unnamed(void)
+{
+ initstack_element *istk = initstk;
+ sym_t *m;
/*
* If the removed element was a structure member, we must go
@@ -480,6 +465,33 @@ initstack_pop_item(void)
/* XXX: duplicate code for skipping unnamed bit-fields */
istk->i_subt = m->s_type;
}
+}
+
+static void
+initstack_pop_item(void)
+{
+ initstack_element *istk;
+
+ debug_enter();
+
+ istk = initstk;
+ debug_step("popping:");
+ debug_initstack_element(istk);
+
+ initstk = istk->i_enclosing;
+ free(istk);
+ istk = initstk;
+ lint_assert(istk != NULL);
+
+ istk->i_remaining--;
+ lint_assert(istk->i_remaining >= 0);
+ debug_step("%d elements remaining", istk->i_remaining);
+
+ if (namedmem != NULL)
+ initstack_pop_item_named_member();
+ else
+ initstack_pop_item_unnamed();
+
debug_initstack();
debug_leave();
}