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: fix initialization with few braces...



details:   https://anonhg.NetBSD.org/src/rev/669c216cfa5e
branches:  trunk
changeset: 1027726:669c216cfa5e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Dec 17 11:06:15 2021 +0000

description:
lint: fix initialization with few braces from function

Seen in Postfix, smtp_proto.c.

diffstat:

 tests/usr.bin/xlint/lint1/init.c   |  11 ++++-------
 tests/usr.bin/xlint/lint1/init.exp |   3 ---
 usr.bin/xlint/lint1/init.c         |   7 ++++---
 3 files changed, 8 insertions(+), 13 deletions(-)

diffs (82 lines):

diff -r a5181c80aa44 -r 669c216cfa5e tests/usr.bin/xlint/lint1/init.c
--- a/tests/usr.bin/xlint/lint1/init.c  Fri Dec 17 10:51:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/init.c  Fri Dec 17 11:06:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.6 2021/12/17 10:51:45 rillig Exp $  */
+/*     $NetBSD: init.c,v 1.7 2021/12/17 11:06:15 rillig Exp $  */
 # 3 "init.c"
 
 /*
@@ -35,7 +35,7 @@
  *
  * Seen in external/ibm-public/postfix/dist/src/util/dict.c(624).
  *
- * TODO: Properly handle this situation; as of init.c 1.214 from 2021-12-17,
+ * TODO: Properly handle this situation; as of init.c 1.215 from 2021-12-17,
  *  the below initialization sets in->in_err but shouldn't.
  */
 const histogram_entry hgr[] = {
@@ -47,7 +47,7 @@
 /*
  * Initialization with fewer braces than usual, must still be accepted.
  *
- * TODO: Properly handle this situation; as of init.c 1.214 from 2021-12-17,
+ * TODO: Properly handle this situation; as of init.c 1.215 from 2021-12-17,
  *  the below initialization sets in->in_err but shouldn't.
  */
 struct {
@@ -60,7 +60,7 @@
 /*
  * Initialization with fewer braces than usual, must still be accepted.
  *
- * TODO: Properly handle this situation; as of init.c 1.214 from 2021-12-17,
+ * TODO: Properly handle this situation; as of init.c 1.215 from 2021-12-17,
  *  the below initialization sets in->in_err but shouldn't.
  */
 void do_nothing(void);
@@ -69,9 +69,6 @@
        void (*action_1) (void);
        void (*action_2) (void);
 } actions[1] = {
-       /* expect+1: error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185] */
        do_nothing,
-       /* expect+2: error: too many array initializers, expected 1 [173] */
-       /* expect+1: error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185] */
        do_nothing,
 };
diff -r a5181c80aa44 -r 669c216cfa5e tests/usr.bin/xlint/lint1/init.exp
--- a/tests/usr.bin/xlint/lint1/init.exp        Fri Dec 17 10:51:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/init.exp        Fri Dec 17 11:06:15 2021 +0000
@@ -1,4 +1,1 @@
 init.c(16): error: empty array declaration: empty_array_with_initializer [190]
-init.c(73): error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185]
-init.c(76): error: too many array initializers, expected 1 [173]
-init.c(76): error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185]
diff -r a5181c80aa44 -r 669c216cfa5e usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Fri Dec 17 10:51:45 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Fri Dec 17 11:06:15 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.214 2021/12/17 10:33:23 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.215 2021/12/17 11:06:15 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.214 2021/12/17 10:33:23 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.215 2021/12/17 11:06:15 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -936,7 +936,8 @@
         * in repeating the same check in lint.  If needed, support for these
         * edge cases could be added, but that would increase the complexity.
         */
-       if (is_scalar(tn->tn_type->t_tspec) &&
+       if ((is_scalar(tn->tn_type->t_tspec) ||
+            tn->tn_type->t_tspec == FUNC) &&
            (tp->t_tspec == ARRAY || is_struct_or_union(tp->t_tspec)) &&
            bl != NULL) {
                bl->bl_confused = true;



Home | Main Index | Thread Index | Old Index