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 alignment when c...



details:   https://anonhg.NetBSD.org/src/rev/a720340b0d2a
branches:  trunk
changeset: 961752:a720340b0d2a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 17 16:58:04 2021 +0000

description:
lint: do not warn about alignment when casting from incomplete struct

This removes a bunch of technically correct but practically useless
warnings from the regular NetBSD build.

diffstat:

 tests/usr.bin/xlint/lint1/msg_135.c   |  8 ++++++--
 tests/usr.bin/xlint/lint1/msg_135.exp |  1 -
 usr.bin/xlint/lint1/tree.c            |  7 ++++---
 3 files changed, 10 insertions(+), 6 deletions(-)

diffs (63 lines):

diff -r 6923d838539b -r a720340b0d2a tests/usr.bin/xlint/lint1/msg_135.c
--- a/tests/usr.bin/xlint/lint1/msg_135.c       Sat Apr 17 16:52:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.c       Sat Apr 17 16:58:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_135.c,v 1.6 2021/04/17 16:52:09 rillig Exp $       */
+/*     $NetBSD: msg_135.c,v 1.7 2021/04/17 16:58:04 rillig Exp $       */
 # 3 "msg_135.c"
 
 // Test for message: converting '%s' to '%s' may cause alignment problem [135]
@@ -28,6 +28,10 @@
  * from the publicly visible, incomplete 'struct lhash_st' to a private
  * implementation type such as 'struct lhash_st_OPENSSL_STRING'.
  *
+ * Before tree.c 1.277 from 2021-04-17, lint warned about this, even though
+ * there was not enough evidence that there really was an alignment problem,
+ * resulting in many false positives.
+ *
  * See openssl/lhash.h.
  */
 void
@@ -35,6 +39,6 @@
 {
        struct complete *complete;
 
-       complete = (struct complete *)incomplete; /* expect: 135 */
+       complete = (struct complete *)incomplete;
        sink(complete);
 }
diff -r 6923d838539b -r a720340b0d2a tests/usr.bin/xlint/lint1/msg_135.exp
--- a/tests/usr.bin/xlint/lint1/msg_135.exp     Sat Apr 17 16:52:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.exp     Sat Apr 17 16:58:04 2021 +0000
@@ -1,3 +1,2 @@
 msg_135.c(15): warning: converting 'pointer to const unsigned char' to 'pointer to const unsigned int' may cause alignment problem [135]
-msg_135.c(38): warning: converting 'pointer to incomplete struct incomplete' to 'pointer to struct complete' may cause alignment problem [135]
 msg_135.c(20): warning: struct incomplete never defined [233]
diff -r 6923d838539b -r a720340b0d2a usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Apr 17 16:52:09 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Apr 17 16:58:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.276 2021/04/10 18:06:53 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.277 2021/04/17 16:58:04 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.276 2021/04/10 18:06:53 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.277 2021/04/17 16:58:04 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2081,7 +2081,8 @@
                return;
        }
 
-       if (hflag && alignment_in_bits(nstp) > alignment_in_bits(ostp)) {
+       if (hflag && alignment_in_bits(nstp) > alignment_in_bits(ostp) &&
+           !is_incomplete(ostp)) {
                /* converting '%s' to '%s' may cause alignment problem */
                warning(135, type_name(otp), type_name(ntp));
        }



Home | Main Index | Thread Index | Old Index