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: do not warn about pointer conversi...



details:   https://anonhg.NetBSD.org/src/rev/ed590700ada7
branches:  trunk
changeset: 1020349:ed590700ada7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 09 20:00:06 2021 +0000

description:
lint: do not warn about pointer conversion to or from incomplete type

This cuts down the warnings in a NetBSD release build by about 38,000.

diffstat:

 tests/usr.bin/xlint/lint1/msg_247.c   |  11 +++++++----
 tests/usr.bin/xlint/lint1/msg_247.exp |   2 --
 usr.bin/xlint/lint1/tree.c            |   7 +++++--
 3 files changed, 12 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r 2fd7acf64939 -r ed590700ada7 tests/usr.bin/xlint/lint1/msg_247.c
--- a/tests/usr.bin/xlint/lint1/msg_247.c       Fri Apr 09 19:52:59 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.c       Fri Apr 09 20:00:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_247.c,v 1.12 2021/04/09 19:32:12 rillig Exp $      */
+/*     $NetBSD: msg_247.c,v 1.13 2021/04/09 20:00:07 rillig Exp $      */
 # 3 "msg_247.c"
 
 // Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
@@ -127,7 +127,7 @@
  * type-generic hashing API while defining a separate struct for each type to
  * be hashed.
  *
- * As of 2021-04-09, in a typical NetBSD build this leads to about 38,000 lint
+ * Before 2021-04-09, in a typical NetBSD build this led to about 38,000 lint
  * warnings about possibly troublesome pointer casts.
  */
 
@@ -147,7 +147,10 @@
 struct lhash_st_OPENSSL_STRING *
 lh_OPENSSL_STRING_new(void)
 {
-       /* expect+1: 247 */
+       /*
+        * Since tree.c 1.274 from 2021-04-09, lint does not warn about casts
+        * to or from incomplete structs anymore.
+        */
        return (struct lhash_st_OPENSSL_STRING *)OPENSSL_LH_new();
 }
-# 154 "msg_247.c" 2
+# 157 "msg_247.c" 2
diff -r 2fd7acf64939 -r ed590700ada7 tests/usr.bin/xlint/lint1/msg_247.exp
--- a/tests/usr.bin/xlint/lint1/msg_247.exp     Fri Apr 09 19:52:59 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.exp     Fri Apr 09 20:00:06 2021 +0000
@@ -1,5 +1,3 @@
 msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct <unnamed>' may be troublesome [247]
 msg_247.c(70): warning: pointer cast from 'pointer to struct Other' to 'pointer to signed char' may be troublesome [247]
-lhash.h(200): warning: pointer cast from 'pointer to incomplete struct lhash_st' to 'pointer to struct lhash_st_OPENSSL_STRING' may be troublesome [247]
-       included from msg_247.c(146)
 msg_247.c(134): warning: struct lhash_st never defined [233]
diff -r 2fd7acf64939 -r ed590700ada7 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Fri Apr 09 19:52:59 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Fri Apr 09 20:00:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.273 2021/04/09 19:52:59 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.274 2021/04/09 20:00:06 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.273 2021/04/09 19:52:59 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.274 2021/04/09 20:00:06 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2036,6 +2036,9 @@
            nstp->t_str->sou_first_member->s_type == ostp)
                return false;
 
+       if (is_incomplete(nstp) || is_incomplete(ostp))
+               return false;
+
        if ((nst == STRUCT || nst == UNION) && nstp->t_str != ostp->t_str)
                return true;
 



Home | Main Index | Thread Index | Old Index