Fri Jan 1 16:50:47 2021 UTC ()
lint: demonstrate bug in handling of nested C9X struct initializers


(rillig)
diff -r1.1005 -r1.1006 src/distrib/sets/lists/tests/mi
diff -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/Makefile
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/d_init_pop_member.c
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp
diff -r1.16 -r1.17 src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -r1.50 -r1.51 src/usr.bin/xlint/lint1/init.c

cvs diff -r1.1005 -r1.1006 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2021/01/01 01:07:07 1.1005
+++ src/distrib/sets/lists/tests/mi 2021/01/01 16:50:47 1.1006
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.1005 2021/01/01 01:07:07 rillig Exp $ 1# $NetBSD: mi,v 1.1006 2021/01/01 16:50:47 rillig Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug compattestdir 6./usr/libdata/debug/usr/tests tests-base-debug compattestdir
7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf 7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf
9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf 9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf
10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf 10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf
11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf 11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf
12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete 12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete
13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete 13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete
14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete 14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete
@@ -5783,26 +5783,28 @@ @@ -5783,26 +5783,28 @@
5783./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp tests-usr.bin-tests compattestfile,atf 5783./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp tests-usr.bin-tests compattestfile,atf
5784./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c tests-usr.bin-tests compattestfile,atf 5784./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c tests-usr.bin-tests compattestfile,atf
5785./usr/tests/usr.bin/xlint/lint1/d_fold_test.c tests-usr.bin-tests compattestfile,atf 5785./usr/tests/usr.bin/xlint/lint1/d_fold_test.c tests-usr.bin-tests compattestfile,atf
5786./usr/tests/usr.bin/xlint/lint1/d_fold_test.exp tests-usr.bin-tests compattestfile,atf 5786./usr/tests/usr.bin/xlint/lint1/d_fold_test.exp tests-usr.bin-tests compattestfile,atf
5787./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c tests-usr.bin-tests compattestfile,atf 5787./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c tests-usr.bin-tests compattestfile,atf
5788./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c tests-usr.bin-tests compattestfile,atf 5788./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c tests-usr.bin-tests compattestfile,atf
5789./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c tests-usr.bin-tests compattestfile,atf 5789./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c tests-usr.bin-tests compattestfile,atf
5790./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.c tests-usr.bin-tests compattestfile,atf 5790./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.c tests-usr.bin-tests compattestfile,atf
5791./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.exp tests-usr.bin-tests compattestfile,atf 5791./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.exp tests-usr.bin-tests compattestfile,atf
5792./usr/tests/usr.bin/xlint/lint1/d_gcc_func.c tests-usr.bin-tests compattestfile,atf 5792./usr/tests/usr.bin/xlint/lint1/d_gcc_func.c tests-usr.bin-tests compattestfile,atf
5793./usr/tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c tests-usr.bin-tests compattestfile,atf 5793./usr/tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c tests-usr.bin-tests compattestfile,atf
5794./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c tests-usr.bin-tests compattestfile,atf 5794./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c tests-usr.bin-tests compattestfile,atf
5795./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp tests-usr.bin-tests compattestfile,atf 5795./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp tests-usr.bin-tests compattestfile,atf
 5796./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.c tests-usr.bin-tests compattestfile,atf
 5797./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.exp tests-usr.bin-tests compattestfile,atf
5796./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf 5798./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf
5797./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-usr.bin-tests compattestfile,atf 5799./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-usr.bin-tests compattestfile,atf
5798./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf 5800./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf
5799./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-usr.bin-tests compattestfile,atf 5801./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-usr.bin-tests compattestfile,atf
5800./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf 5802./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf
5801./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf 5803./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf
5802./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-usr.bin-tests compattestfile,atf 5804./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-usr.bin-tests compattestfile,atf
5803./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf 5805./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf
5804./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf 5806./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf
5805./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf 5807./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf
5806./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf 5808./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf
5807./usr/tests/usr.bin/xlint/lint1/d_type_conv1.exp tests-usr.bin-tests compattestfile,atf 5809./usr/tests/usr.bin/xlint/lint1/d_type_conv1.exp tests-usr.bin-tests compattestfile,atf
5808./usr/tests/usr.bin/xlint/lint1/d_type_conv2.c tests-usr.bin-tests compattestfile,atf 5810./usr/tests/usr.bin/xlint/lint1/d_type_conv2.c tests-usr.bin-tests compattestfile,atf

cvs diff -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/Makefile (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Makefile 2021/01/01 01:07:08 1.23
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/01/01 16:50:47 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.23 2021/01/01 01:07:08 rillig Exp $ 1# $NetBSD: Makefile,v 1.24 2021/01/01 16:50:47 rillig Exp $
2 2
3NOMAN= # defined 3NOMAN= # defined
4 4
5.include <bsd.own.mk> 5.include <bsd.own.mk>
6 6
7TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 7TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1
8 8
9TESTS_SH= t_integration 9TESTS_SH= t_integration
10 10
11FILESDIR= ${TESTSDIR} 11FILESDIR= ${TESTSDIR}
12FILES+= d_alignof.c 12FILES+= d_alignof.c
13FILES+= d_bltinoffsetof.c 13FILES+= d_bltinoffsetof.c
14FILES+= d_c99_anon_struct.c 14FILES+= d_c99_anon_struct.c
@@ -51,26 +51,28 @@ FILES+= d_decl_old_style_arguments.c @@ -51,26 +51,28 @@ FILES+= d_decl_old_style_arguments.c
51FILES+= d_decl_old_style_arguments.exp 51FILES+= d_decl_old_style_arguments.exp
52FILES+= d_ellipsis_in_switch.c 52FILES+= d_ellipsis_in_switch.c
53FILES+= d_fold_test.c 53FILES+= d_fold_test.c
54FILES+= d_fold_test.exp 54FILES+= d_fold_test.exp
55FILES+= d_gcc_compound_statements1.c 55FILES+= d_gcc_compound_statements1.c
56FILES+= d_gcc_compound_statements2.c 56FILES+= d_gcc_compound_statements2.c
57FILES+= d_gcc_compound_statements3.c 57FILES+= d_gcc_compound_statements3.c
58FILES+= d_gcc_extension.c 58FILES+= d_gcc_extension.c
59FILES+= d_gcc_extension.exp 59FILES+= d_gcc_extension.exp
60FILES+= d_gcc_func.c 60FILES+= d_gcc_func.c
61FILES+= d_gcc_variable_array_init.c 61FILES+= d_gcc_variable_array_init.c
62FILES+= d_incorrect_array_size.c 62FILES+= d_incorrect_array_size.c
63FILES+= d_incorrect_array_size.exp 63FILES+= d_incorrect_array_size.exp
 64FILES+= d_init_pop_member.c
 65FILES+= d_init_pop_member.exp
64FILES+= d_long_double_int.c 66FILES+= d_long_double_int.c
65FILES+= d_long_double_int.exp 67FILES+= d_long_double_int.exp
66FILES+= d_nested_structs.c 68FILES+= d_nested_structs.c
67FILES+= d_nolimit_init.c 69FILES+= d_nolimit_init.c
68FILES+= d_packed_structs.c 70FILES+= d_packed_structs.c
69FILES+= d_return_type.c 71FILES+= d_return_type.c
70FILES+= d_return_type.exp 72FILES+= d_return_type.exp
71FILES+= d_shift_to_narrower_type.c 73FILES+= d_shift_to_narrower_type.c
72FILES+= d_struct_init_nested.c 74FILES+= d_struct_init_nested.c
73FILES+= d_struct_init_nested.exp 75FILES+= d_struct_init_nested.exp
74FILES+= d_type_conv1.c 76FILES+= d_type_conv1.c
75FILES+= d_type_conv1.exp 77FILES+= d_type_conv1.exp
76FILES+= d_type_conv2.c 78FILES+= d_type_conv2.c

File Added: src/tests/usr.bin/xlint/lint1/d_init_pop_member.c
# 2

/*
 * Between init.c 1.27 from 2015-07-28 and init.c 1.52 from 2021-01-01,
 * a bug in memberpop or pop_member led to a wrong error message
 * "undefined struct/union member: capital [101]" in the second and third
 * named initializer.
 */

struct rgb {
	unsigned red;
	unsigned green;
	unsigned blue;
};

struct hobbies {
	unsigned dancing: 1;
	unsigned running: 1;
	unsigned swimming: 1;
};

struct person {
	struct hobbies hobbies;
	struct rgb favorite_color;
};

struct city {
	struct person major;
};

struct state {
	struct city capital;
};

void func(void)
{
	struct state st = {
	    .capital.major.hobbies.dancing = 1,
	    /*
	     * Between 2015-07-28 and 2021-01-01:
	     * wrong "undefined struct/union member: capital [101]"
	     */
	    /*
	     * As of 2020-01-01:
	     * wrong "warning: bit-field initializer does not fit [180]"
	     */
	    .capital.major.favorite_color.green = 0xFF,
	    /*
	     * Between 2015-07-28 and 2021-01-01:
	     * wrong "undefined struct/union member: capital [101]"
	     */
	    /*
	     * As of 2020-01-01:
	     * wrong "warning: bit-field initializer does not fit [180]"
	     */
	    .capital.major.favorite_color.red = 0xFF
	};
}

File Added: src/tests/usr.bin/xlint/lint1/Attic/d_init_pop_member.exp
(47): undefined struct/union member: capital [101]
(47): warning: bit-field initializer does not fit [180]
(57): undefined struct/union member: capital [101]
(57): warning: bit-field initializer does not fit [180]

cvs diff -r1.16 -r1.17 src/tests/usr.bin/xlint/lint1/t_integration.sh (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/t_integration.sh 2021/01/01 01:07:08 1.16
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh 2021/01/01 16:50:47 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: t_integration.sh,v 1.16 2021/01/01 01:07:08 rillig Exp $ 1# $NetBSD: t_integration.sh,v 1.17 2021/01/01 16:50:47 rillig Exp $
2# 2#
3# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. 3# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# Redistribution and use in source and binary forms, with or without 6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions 7# modification, are permitted provided that the following conditions
8# are met: 8# are met:
9# 1. Redistributions of source code must retain the above copyright 9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer. 10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright 11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the 12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution. 13# documentation and/or other materials provided with the distribution.
14# 14#
@@ -66,26 +66,27 @@ test_case bltinoffsetof @@ -66,26 +66,27 @@ test_case bltinoffsetof
66test_case c99_anon_struct 66test_case c99_anon_struct
67test_case c99_anon_union 67test_case c99_anon_union
68test_case c99_compound_literal_comma 68test_case c99_compound_literal_comma
69test_case c99_decls_after_stmt2 69test_case c99_decls_after_stmt2
70test_case c99_flex_array_packed 70test_case c99_flex_array_packed
71test_case c99_nested_struct 71test_case c99_nested_struct
72test_case c99_union_cast 72test_case c99_union_cast
73test_case c99_union_init4 73test_case c99_union_init4
74test_case cast_fun_array_param 74test_case cast_fun_array_param
75test_case cast_typeof 75test_case cast_typeof
76test_case decl_old_style_arguments 76test_case decl_old_style_arguments
77test_case fold_test 77test_case fold_test
78test_case gcc_extension 78test_case gcc_extension
 79test_case init_pop_member
79test_case return_type 80test_case return_type
80test_case type_question_colon 81test_case type_question_colon
81test_case typefun 82test_case typefun
82test_case typename_as_var 83test_case typename_as_var
83 84
84test_case c99_struct_init 85test_case c99_struct_init
85test_case c99_union_init1 86test_case c99_union_init1
86test_case c99_union_init2 87test_case c99_union_init2
87test_case c99_union_init3 88test_case c99_union_init3
88test_case c99_recursive_init 89test_case c99_recursive_init
89test_case c9x_recursive_init 90test_case c9x_recursive_init
90test_case nested_structs 91test_case nested_structs
91test_case packed_structs 92test_case packed_structs

cvs diff -r1.50 -r1.51 src/usr.bin/xlint/lint1/init.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/init.c 2021/01/01 11:41:01 1.50
+++ src/usr.bin/xlint/lint1/init.c 2021/01/01 16:50:47 1.51
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: init.c,v 1.50 2021/01/01 11:41:01 rillig Exp $ */ 1/* $NetBSD: init.c,v 1.51 2021/01/01 16:50:47 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: init.c,v 1.50 2021/01/01 11:41:01 rillig Exp $"); 40__RCSID("$NetBSD: init.c,v 1.51 2021/01/01 16:50:47 rillig Exp $");
41#endif 41#endif
42 42
43#include <ctype.h> 43#include <ctype.h>
44#include <stdlib.h> 44#include <stdlib.h>
45#include <string.h> 45#include <string.h>
46 46
47#include "lint1.h" 47#include "lint1.h"
48 48
49/* 49/*
50 * initerr is set as soon as a fatal error occurred in an initialisation. 50 * initerr is set as soon as a fatal error occurred in an initialisation.
51 * The effect is that the rest of the initialisation is ignored (parsed 51 * The effect is that the rest of the initialisation is ignored (parsed
52 * by yacc, expression trees built, but no initialisation takes place). 52 * by yacc, expression trees built, but no initialisation takes place).
53 */ 53 */
@@ -68,54 +68,58 @@ typedef struct namlist { @@ -68,54 +68,58 @@ typedef struct namlist {
68/* Points to a c9x named member; */ 68/* Points to a c9x named member; */
69namlist_t *namedmem = NULL; 69namlist_t *namedmem = NULL;
70 70
71 71
72static int initstack_string(tnode_t *); 72static int initstack_string(tnode_t *);
73 73
74#ifndef DEBUG 74#ifndef DEBUG
75#define DPRINTF(a) 75#define DPRINTF(a)
76#else 76#else
77#define DPRINTF(a) printf a 77#define DPRINTF(a) printf a
78#endif 78#endif
79 79
80void 80void
81push_member(sb) 81push_member(sbuf_t *sb)
82 sbuf_t *sb; 
83{ 82{
84 namlist_t *nam = xcalloc(1, sizeof (namlist_t)); 83 namlist_t *nam = xcalloc(1, sizeof (namlist_t));
85 nam->n_name = sb->sb_name; 84 nam->n_name = sb->sb_name;
86 DPRINTF(("%s: %s %p\n", __func__, nam->n_name, nam)); 85 DPRINTF(("%s: %s %p\n", __func__, nam->n_name, nam));
87 if (namedmem == NULL) { 86 if (namedmem == NULL) {
 87 /*
 88 * XXX: Why is this a circular list?
 89 * XXX: Why is this a doubly-linked list?
 90 * A simple stack should suffice.
 91 */
88 nam->n_prev = nam->n_next = nam; 92 nam->n_prev = nam->n_next = nam;
89 namedmem = nam; 93 namedmem = nam;
90 } else { 94 } else {
91 namedmem->n_prev->n_next = nam; 95 namedmem->n_prev->n_next = nam;
92 nam->n_prev = namedmem->n_prev; 96 nam->n_prev = namedmem->n_prev;
93 nam->n_next = namedmem; 97 nam->n_next = namedmem;
94 namedmem->n_prev = nam; 98 namedmem->n_prev = nam;
95 } 99 }
96} 100}
97 101
98static void 102static void
99pop_member(void) 103pop_member(void)
100{ 104{
101 DPRINTF(("%s: %s %p\n", __func__, namedmem->n_name, namedmem)); 105 DPRINTF(("%s: %s %p\n", __func__, namedmem->n_name, namedmem));
102 if (namedmem->n_next == namedmem) { 106 if (namedmem->n_next == namedmem) {
103 free(namedmem); 107 free(namedmem);
104 namedmem = NULL; 108 namedmem = NULL;
105 } else { 109 } else {
106 namlist_t *nam = namedmem; 110 namlist_t *nam = namedmem;
107 namedmem = namedmem->n_next; 111 namedmem = namedmem->n_next;
108 namedmem->n_next = nam->n_next; 112 namedmem->n_next = nam->n_next; /* FIXME: inner circle */
109 namedmem->n_prev = nam->n_prev; 113 namedmem->n_prev = nam->n_prev;
110 free(nam); 114 free(nam);
111 } 115 }
112} 116}
113 117
114 118
115/* 119/*
116 * Initialize the initialisation stack by putting an entry for the variable 120 * Initialize the initialisation stack by putting an entry for the variable
117 * which is to be initialized on it. 121 * which is to be initialized on it.
118 */ 122 */
119void 123void
120initstack_init(void) 124initstack_init(void)
121{ 125{