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 warning ab...
details: https://anonhg.NetBSD.org/src/rev/caa8233db8a1
branches: trunk
changeset: 950769:caa8233db8a1
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jan 30 21:49:08 2021 +0000
description:
lint: add type information to warning about troublesome casts
The previous warning text did not mention the actual types that are
involved in the type conversion. These types can be hard to see from
the source code as soon as macros are involved, and even in plain code,
one would have to follow the declarations, which is an unnecessary
burden. Lint already has all information about the involved types, so
there is no reason for omitting this crucial information.
Seen in external/mit/lua/dist/src/lvm.c and several other files.
Including the type information in the message immediately makes the
message scarier.
Before: pointer casts may be troublesome
After: pointer cast from 'pointer to struct TString' to 'pointer to
union GCUnion' may be troublesome
diffstat:
usr.bin/xlint/lint1/err.c | 6 +++---
usr.bin/xlint/lint1/tree.c | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diffs (56 lines):
diff -r 26e10df088c7 -r caa8233db8a1 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sat Jan 30 21:26:32 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sat Jan 30 21:49:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.70 2021/01/30 17:56:29 rillig Exp $ */
+/* $NetBSD: err.c,v 1.71 2021/01/30 21:49:08 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.70 2021/01/30 17:56:29 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.71 2021/01/30 21:49:08 rillig Exp $");
#endif
#include <sys/types.h>
@@ -306,7 +306,7 @@
"illegal structure pointer combination", /* 244 */
"illegal structure pointer combination, op %s", /* 245 */
"dubious conversion of enum to '%s'", /* 246 */
- "pointer casts may be troublesome", /* 247 */
+ "pointer cast from '%s' to '%s' may be troublesome", /* 247 */
"floating-point constant out of range", /* 248 */
"syntax error '%s'", /* 249 */
"unknown character \\%o", /* 250 */
diff -r 26e10df088c7 -r caa8233db8a1 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Jan 30 21:26:32 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Jan 30 21:49:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.194 2021/01/30 18:16:45 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.195 2021/01/30 21:49:08 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.194 2021/01/30 18:16:45 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.195 2021/01/30 21:49:08 rillig Exp $");
#endif
#include <float.h>
@@ -2253,8 +2253,8 @@
tp->t_subt->t_str != tn->tn_type->t_subt->t_str) ||
psize(nt) != psize(ot)) {
if (cflag) {
- /* pointer casts may be troublesome */
- warning(247);
+ /* pointer cast from '%s' to '%s' may be troublesome */
+ warning(247, type_name(tn->tn_type), type_name(tp));
}
}
}
Home |
Main Index |
Thread Index |
Old Index