Module Name: src Committed By: rillig Date: Fri Jan 1 19:11:20 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: d_init_pop_member.c d_init_pop_member.exp src/usr.bin/xlint/lint1: init.c Log Message: lint: fix wrong warning about bitfield in C99 structure initialization The variable namemem is supposed to be a circular list, which is "documented" implicitly in push_member. The implementation was buggy though. In pop_member, the circular list was destroyed though. Given the list (capital, major, favorite_color, green), removing capital made major point to itself in the forward direction, even though it should not have been modified at all. In the test, I had been too optimistic to quickly understand the code around variable initialization. I was wrong though, so I had to adjust the comments there to reality. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_init_pop_member.c \ src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/lint1/init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/d_init_pop_member.c diff -u src/tests/usr.bin/xlint/lint1/d_init_pop_member.c:1.1 src/tests/usr.bin/xlint/lint1/d_init_pop_member.c:1.2 --- src/tests/usr.bin/xlint/lint1/d_init_pop_member.c:1.1 Fri Jan 1 16:50:47 2021 +++ src/tests/usr.bin/xlint/lint1/d_init_pop_member.c Fri Jan 1 19:11:20 2021 @@ -1,7 +1,7 @@ # 2 /* - * Between init.c 1.27 from 2015-07-28 and init.c 1.52 from 2021-01-01, + * Since init.c 1.27 from 2015-07-28, * 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. @@ -37,20 +37,20 @@ void func(void) struct state st = { .capital.major.hobbies.dancing = 1, /* - * Between 2015-07-28 and 2021-01-01: + * Since 2015-07-28: * wrong "undefined struct/union member: capital [101]" */ /* - * As of 2020-01-01: + * Before init.c 1.52 from 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: + * Since 2015-07-28: * wrong "undefined struct/union member: capital [101]" */ /* - * As of 2020-01-01: + * Before init.c 1.52 from 2020-01-01: * wrong "warning: bit-field initializer does not fit [180]" */ .capital.major.favorite_color.red = 0xFF Index: src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp diff -u src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp:1.1 src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp:1.2 --- src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp:1.1 Fri Jan 1 16:50:47 2021 +++ src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp Fri Jan 1 19:11:20 2021 @@ -1,4 +1,2 @@ (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] Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.51 src/usr.bin/xlint/lint1/init.c:1.52 --- src/usr.bin/xlint/lint1/init.c:1.51 Fri Jan 1 16:50:47 2021 +++ src/usr.bin/xlint/lint1/init.c Fri Jan 1 19:11:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.51 2021/01/01 16:50:47 rillig Exp $ */ +/* $NetBSD: init.c,v 1.52 2021/01/01 19:11:19 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.51 2021/01/01 16:50:47 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.52 2021/01/01 19:11:19 rillig Exp $"); #endif #include <ctype.h> @@ -109,8 +109,8 @@ pop_member(void) } else { namlist_t *nam = namedmem; namedmem = namedmem->n_next; - namedmem->n_next = nam->n_next; /* FIXME: inner circle */ - namedmem->n_prev = nam->n_prev; + nam->n_prev->n_next = nam->n_next; + nam->n_next->n_prev = nam->n_prev; free(nam); } }