Module Name:    src
Committed By:   rillig
Date:           Fri Apr  9 20:00:07 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_247.c msg_247.exp
        src/usr.bin/xlint/lint1: tree.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/msg_247.c
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_247.exp
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/xlint/lint1/tree.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/msg_247.c
diff -u src/tests/usr.bin/xlint/lint1/msg_247.c:1.12 src/tests/usr.bin/xlint/lint1/msg_247.c:1.13
--- src/tests/usr.bin/xlint/lint1/msg_247.c:1.12	Fri Apr  9 19:32:12 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.c	Fri Apr  9 20:00:07 2021
@@ -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 @@ counter_increment(struct counter *counte
  * 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 {
 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

Index: src/tests/usr.bin/xlint/lint1/msg_247.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.9 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.10
--- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.9	Fri Apr  9 19:37:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.exp	Fri Apr  9 20:00:07 2021
@@ -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]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.273 src/usr.bin/xlint/lint1/tree.c:1.274
--- src/usr.bin/xlint/lint1/tree.c:1.273	Fri Apr  9 19:52:59 2021
+++ src/usr.bin/xlint/lint1/tree.c	Fri Apr  9 20:00:06 2021
@@ -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 @@ should_warn_about_pointer_cast(const typ
 	    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;
 

Reply via email to