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: add type information to 'possible ...



details:   https://anonhg.NetBSD.org/src/rev/aea2a54b8b77
branches:  trunk
changeset: 1019134:aea2a54b8b77
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 28 00:40:22 2021 +0000

description:
lint: add type information to 'possible pointer alignment problem [135]'

This warning occurs more than 7400 times in a regular NetBSD build, and
without giving any type information, leaves the reader clueless about
what the underlying issue might be.  Add type information since that is
a no-brainer to implement.

diffstat:

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

diffs (75 lines):

diff -r 0c5c92426530 -r aea2a54b8b77 tests/usr.bin/xlint/lint1/msg_135.c
--- a/tests/usr.bin/xlint/lint1/msg_135.c       Sun Feb 28 00:28:47 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.c       Sun Feb 28 00:40:22 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_135.c,v 1.3 2021/02/28 00:20:19 rillig Exp $       */
+/*     $NetBSD: msg_135.c,v 1.4 2021/02/28 00:40:22 rillig Exp $       */
 # 3 "msg_135.c"
 
-// Test for message: possible pointer alignment problem [135]
+// Test for message: converting '%s' to '%s' may cause alignment problem [135]
 
 /* lint1-extra-flags: -h */
 
diff -r 0c5c92426530 -r aea2a54b8b77 tests/usr.bin/xlint/lint1/msg_135.exp
--- a/tests/usr.bin/xlint/lint1/msg_135.exp     Sun Feb 28 00:28:47 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.exp     Sun Feb 28 00:40:22 2021 +0000
@@ -1,1 +1,1 @@
-msg_135.c(13): warning: possible pointer alignment problem [135]
+msg_135.c(13): warning: converting 'pointer to const unsigned char' to 'pointer to const unsigned int' may cause alignment problem [135]
diff -r 0c5c92426530 -r aea2a54b8b77 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Feb 28 00:28:47 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Feb 28 00:40:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.81 2021/02/22 15:09:50 rillig Exp $  */
+/*     $NetBSD: err.c,v 1.82 2021/02/28 00:40:22 rillig Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.81 2021/02/22 15:09:50 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.82 2021/02/28 00:40:22 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -194,7 +194,7 @@
        "conversion from '%s' to '%s' may lose accuracy",             /* 132 */
        "conversion of pointer to '%s' loses bits",                   /* 133 */
        "conversion of pointer to '%s' may lose bits",                /* 134 */
-       "possible pointer alignment problem",                         /* 135 */
+       "converting '%s' to '%s' may cause alignment problem",        /* 135 */
        "cannot do pointer arithmetic on operand of unknown size",    /* 136 */
        "use of incomplete enum type, op %s",                         /* 137 */
        "unknown operand size, op %s",                                /* 138 */
diff -r 0c5c92426530 -r aea2a54b8b77 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Feb 28 00:28:47 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Feb 28 00:40:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.221 2021/02/28 00:28:47 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.222 2021/02/28 00:40:22 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.221 2021/02/28 00:28:47 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.222 2021/02/28 00:40:22 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2245,8 +2245,8 @@
 
        if (hflag && alignment_in_bits(tp->t_subt) >
                     alignment_in_bits(tn->tn_type->t_subt)) {
-               /* possible pointer alignment problem */
-               warning(135);
+               /* converting '%s' to '%s' may cause alignment problem */
+               warning(135, type_name(tn->tn_type), type_name(tp));
        }
 
        if (((nt == STRUCT || nt == UNION) &&



Home | Main Index | Thread Index | Old Index