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: extract brace_level_subtype



details:   https://anonhg.NetBSD.org/src/rev/e82c76c4c691
branches:  trunk
changeset: 960771:e82c76c4c691
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 28 16:28:15 2021 +0000

description:
lint: extract brace_level_subtype

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diffs (74 lines):

diff -r 5179b6d48339 -r e82c76c4c691 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sun Mar 28 16:19:21 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Mar 28 16:28:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.165 2021/03/28 16:19:21 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.166 2021/03/28 16:28:15 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.165 2021/03/28 16:19:21 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.166 2021/03/28 16:28:15 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -474,13 +474,15 @@
 
 
 static struct brace_level *
-brace_level_new(type_t *type, type_t *subtype, int remaining)
+brace_level_new(type_t *type, type_t *subtype, int remaining,
+               struct brace_level *enclosing)
 {
        struct brace_level *level = xcalloc(1, sizeof(*level));
 
        level->bl_type = type;
        level->bl_subtype = subtype;
        level->bl_remaining = remaining;
+       level->bl_enclosing = enclosing;
 
        return level;
 }
@@ -526,6 +528,16 @@
 #define brace_level_debug(level) do { } while (false)
 #endif
 
+static type_t *
+brace_level_subtype(struct brace_level *level)
+{
+
+       if (level->bl_subtype != NULL)
+               return level->bl_subtype;
+
+       return level->bl_type;
+}
+
 static void
 brace_level_set_array_dimension(struct brace_level *level, int dim)
 {
@@ -776,7 +788,7 @@
                in->initsym->s_type = duptyp(in->initsym->s_type);
        /* TODO: does 'duptyp' create a memory leak? */
 
-       in->brace_level = brace_level_new(NULL, in->initsym->s_type, 1);
+       in->brace_level = brace_level_new(NULL, in->initsym->s_type, 1, NULL);
 
        initialization_debug(in);
        debug_leave();
@@ -867,10 +879,8 @@
        level = in->brace_level;
        lint_assert(level->bl_remaining > 0);
 
-       in->brace_level = brace_level_new(
-           level->bl_subtype != NULL ? level->bl_subtype : level->bl_type,
-           NULL, 0);
-       in->brace_level->bl_enclosing = level;
+       in->brace_level = brace_level_new(brace_level_subtype(level), NULL, 0,
+           level);
        lint_assert(in->brace_level->bl_type != NULL);
        lint_assert(in->brace_level->bl_type->t_tspec != FUNC);
 



Home | Main Index | Thread Index | Old Index