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: inline initerr in code for handlin...



details:   https://anonhg.NetBSD.org/src/rev/785082b182de
branches:  trunk
changeset: 960746:785082b182de
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 28 09:39:04 2021 +0000

description:
lint: inline initerr in code for handling initializations

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  59 ++++++++++++++++++++++++---------------------
 1 files changed, 32 insertions(+), 27 deletions(-)

diffs (187 lines):

diff -r 2561a20ecfd3 -r 785082b182de usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sun Mar 28 09:34:45 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Mar 28 09:39:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.149 2021/03/28 09:34:45 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.150 2021/03/28 09:39:04 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.149 2021/03/28 09:34:45 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.150 2021/03/28 09:39:04 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -533,6 +533,13 @@
 #define initialization_debug(in) do { } while (false)
 #endif
 
+static void
+initialization_set_error(struct initialization *in)
+{
+       in->initerr = true;
+}
+
+
 /* XXX: unnecessary prototype since it is not recursive */
 static bool    init_array_using_string(struct initialization *, tnode_t *);
 
@@ -556,13 +563,6 @@
        return &current_init()->initsym;
 }
 
-static void
-set_initerr(void)
-{
-       current_init()->initerr = true;
-}
-
-#define initerr                (*current_initerr())
 #define initsym                (*current_initsym())
 
 #ifndef DEBUG
@@ -704,8 +704,9 @@
 void
 initstack_init(void)
 {
+       struct initialization *in = current_init();
 
-       if (initerr)
+       if (in->initerr)
                return;
 
        debug_enter();
@@ -742,7 +743,7 @@
            level->bl_type->t_tspec != UNION) {
                /* syntax error '%s' */
                error(249, "named member must only be used with struct/union");
-               set_initerr();
+               initialization_set_error(in);
                return;
        }
 
@@ -901,7 +902,7 @@
            level->bl_enclosing->bl_enclosing != NULL) {
                /* initialization of an incomplete type */
                error(175);
-               set_initerr();
+               initialization_set_error(in);
                return;
        }
 
@@ -930,7 +931,7 @@
        if (is_incomplete(level->bl_type)) {
                /* initialization of an incomplete type */
                error(175);
-               set_initerr();
+               initialization_set_error(in);
                return false;
        }
 
@@ -964,7 +965,7 @@
        if (cnt == 0) {
                /* cannot init. struct/union with no named member */
                error(179);
-               set_initerr();
+               initialization_set_error(in);
                return false;
        }
        level->bl_remaining = level->bl_type->t_tspec == STRUCT ? cnt : 1;
@@ -1040,7 +1041,9 @@
 static void
 check_too_many_initializers(void)
 {
-       const struct brace_level *level = current_init()->brace_level;
+       struct initialization *in = current_init();
+       const struct brace_level *level = in->brace_level;
+
        if (level->bl_remaining > 0)
                return;
        /*
@@ -1060,7 +1063,7 @@
                /* too many initializers */
                error(174);
        }
-       set_initerr();
+       initialization_set_error(in);
 }
 
 /*
@@ -1079,13 +1082,13 @@
            is_scalar(in->brace_level->bl_type->t_tspec)) {
                /* invalid initializer type %s */
                error(176, type_name(in->brace_level->bl_type));
-               set_initerr();
+               initialization_set_error(in);
        }
-       if (!initerr)
+       if (!in->initerr)
                check_too_many_initializers();
-       if (!initerr)
+       if (!in->initerr)
                initstack_push(in);
-       if (!initerr) {
+       if (!in->initerr) {
                in->brace_level->bl_brace = true;
                designation_debug(&in->designation);
                debug_step("expecting type '%s'",
@@ -1111,10 +1114,10 @@
                /* XXX: maybe set initerr here */
        }
 
-       if (!initerr)
+       if (!in->initerr)
                check_too_many_initializers();
 
-       while (!initerr) {
+       while (!in->initerr) {
                struct brace_level *level = in->brace_level;
 
                if (tn->tn_type->t_tspec == STRUCT &&
@@ -1142,7 +1145,7 @@
 {
        struct initialization *in = current_init();
 
-       if (initerr)
+       if (in->initerr)
                return;
 
        debug_enter();
@@ -1175,11 +1178,13 @@
 void
 init_rbrace(void)
 {
-       if (initerr)
+       struct initialization *in = current_init();
+
+       if (in->initerr)
                return;
 
        debug_enter();
-       initstack_pop_brace(current_init());
+       initstack_pop_brace(in);
        debug_leave();
 }
 
@@ -1302,7 +1307,7 @@
        debug_step("expr:");
        debug_node(tn, debug_ind + 1);
 
-       if (initerr || tn == NULL)
+       if (in->initerr || tn == NULL)
                goto done;
 
        sclass = initsym->s_scl;
@@ -1318,7 +1323,7 @@
        }
 
        initstack_next_nobrace(in, tn);
-       if (initerr || tn == NULL)
+       if (in->initerr || tn == NULL)
                goto done_initstack;
 
        in->brace_level->bl_remaining--;



Home | Main Index | Thread Index | Old Index