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: move code for extending an array o...



details:   https://anonhg.NetBSD.org/src/rev/ea906d922575
branches:  trunk
changeset: 954050:ea906d922575
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 28 11:08:01 2021 +0000

description:
lint: move code for extending an array of unknown size further up

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  64 ++++++++++++++++++++++-----------------------
 1 files changed, 31 insertions(+), 33 deletions(-)

diffs (99 lines):

diff -r 40f4776fa3af -r ea906d922575 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sun Mar 28 10:58:18 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Mar 28 11:08:01 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.159 2021/03/28 10:58:18 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.160 2021/03/28 11:08:01 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.159 2021/03/28 10:58:18 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.160 2021/03/28 11:08:01 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -676,6 +676,34 @@
        return false;
 }
 
+/* Extend an array of unknown size by one element */
+static void
+brace_level_extend_if_array_of_unknown_size(struct brace_level *level)
+{
+
+       if (level->bl_remaining != 0)
+               return;
+       /*
+        * XXX: According to the function name, there should be a 'return' if
+        * bl_array_of_unknown_size is false.  There's probably a test missing
+        * for that case.
+        */
+
+       /*
+        * The only place where an incomplete array may appear is at the
+        * outermost aggregate level of the object to be initialized.
+        */
+       lint_assert(level->bl_enclosing->bl_enclosing == NULL);
+       lint_assert(level->bl_type->t_tspec == ARRAY);
+
+       debug_step("extending array of unknown size '%s'",
+           type_name(level->bl_type));
+       level->bl_remaining = 1;
+       level->bl_type->t_dim++;
+       setcomplete(level->bl_type, true);
+
+       debug_step("extended type is '%s'", type_name(level->bl_type));
+}
 
 
 static struct initialization *
@@ -817,36 +845,6 @@
        return false;
 }
 
-/* Extend an array of unknown size by one element */
-static void
-initialization_extend_if_array_of_unknown_size(struct initialization *in)
-{
-       struct brace_level *level = in->brace_level;
-
-       if (level->bl_remaining != 0)
-               return;
-       /*
-        * XXX: According to the function name, there should be a 'return' if
-        * bl_array_of_unknown_size is false.  There's probably a test missing
-        * for that case.
-        */
-
-       /*
-        * The only place where an incomplete array may appear is at the
-        * outermost aggregate level of the object to be initialized.
-        */
-       lint_assert(level->bl_enclosing->bl_enclosing == NULL);
-       lint_assert(level->bl_type->t_tspec == ARRAY);
-
-       debug_step("extending array of unknown size '%s'",
-           type_name(level->bl_type));
-       level->bl_remaining = 1;
-       level->bl_type->t_dim++;
-       setcomplete(level->bl_type, true);
-
-       debug_step("extended type is '%s'", type_name(level->bl_type));
-}
-
 /* TODO: document me */
 /* TODO: think of a better name than 'push' */
 static void
@@ -856,7 +854,7 @@
 
        debug_enter();
 
-       initialization_extend_if_array_of_unknown_size(in);
+       brace_level_extend_if_array_of_unknown_size(in->brace_level);
 
        level = in->brace_level;
        lint_assert(level->bl_remaining > 0);



Home | Main Index | Thread Index | Old Index