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: merge duplicate code in initializa...



details:   https://anonhg.NetBSD.org/src/rev/ba1709453b07
branches:  trunk
changeset: 960715:ba1709453b07
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 27 13:08:20 2021 +0000

description:
lint: merge duplicate code in initialization

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diffs (96 lines):

diff -r c8c9e5f544d6 -r ba1709453b07 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sat Mar 27 12:42:22 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sat Mar 27 13:08:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.134 2021/03/26 20:31:07 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.135 2021/03/27 13:08:20 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.134 2021/03/26 20:31:07 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.135 2021/03/27 13:08:20 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -215,8 +215,9 @@
 } initstack_element;
 
 /*
- * Leads the path to the sub-object to initialize using the expression.
- * Example designators are '.member' or '.member[123].member.member[1][1]'.
+ * A single component on the path to the sub-object that is initialized by an
+ * initializer expression.  Either a struct or union member, or an array
+ * subscript.
  *
  * See also: C99 6.7.8 "Initialization"
  */
@@ -227,6 +228,10 @@
 } designator;
 
 /*
+ * The optional designation for an initializer, saying which sub-object to
+ * initialize.  Examples for designations are '.member' or
+ * '.member[123].member.member[1][1]'.
+ *
  * See also: C99 6.7.8 "Initialization"
  */
 typedef struct {
@@ -265,27 +270,29 @@
 static bool    init_array_using_string(tnode_t *);
 
 
-/* TODO: replace the following functions with current_init */
+static struct initialization *
+current_init(void)
+{
+       lint_assert(init != NULL);
+       return init;
+}
 
 bool *
 current_initerr(void)
 {
-       lint_assert(init != NULL);
-       return &init->initerr;
+       return &current_init()->initerr;
 }
 
 sym_t **
 current_initsym(void)
 {
-       lint_assert(init != NULL);
-       return &init->initsym;
+       return &current_init()->initsym;
 }
 
 static designation *
 current_designation_mod(void)
 {
-       lint_assert(init != NULL);
-       return &init->designation;
+       return &current_init()->designation;
 }
 
 static designation
@@ -297,15 +304,13 @@
 static const initstack_element *
 current_initstk(void)
 {
-       lint_assert(init != NULL);
-       return init->initstk;
+       return current_init()->initstk;
 }
 
 static initstack_element **
 current_initstk_lvalue(void)
 {
-       lint_assert(init != NULL);
-       return &init->initstk;
+       return &current_init()->initstk;
 }
 
 static void



Home | Main Index | Thread Index | Old Index