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: allow pointer cast to 'char *' and...
details: https://anonhg.NetBSD.org/src/rev/484bbe1196ea
branches: trunk
changeset: 953968:484bbe1196ea
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Mar 26 16:59:18 2021 +0000
description:
lint: allow pointer cast to 'char *' and 'unsigned char *'
This reduces the number of warnings in the regular NetBSD build by 5560.
diffstat:
tests/usr.bin/xlint/lint1/msg_247.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_247.exp | 2 --
usr.bin/xlint/lint1/tree.c | 7 +++++--
3 files changed, 8 insertions(+), 7 deletions(-)
diffs (63 lines):
diff -r 4f4ffa5253ba -r 484bbe1196ea tests/usr.bin/xlint/lint1/msg_247.c
--- a/tests/usr.bin/xlint/lint1/msg_247.c Fri Mar 26 16:53:19 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.c Fri Mar 26 16:59:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_247.c,v 1.6 2021/03/26 16:19:43 rillig Exp $ */
+/* $NetBSD: msg_247.c,v 1.7 2021/03/26 16:59:19 rillig Exp $ */
# 3 "msg_247.c"
// Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
@@ -45,7 +45,7 @@
char *
cast_to_char_pointer(struct Other *arg)
{
- return (char *)arg; /* expect: 247 *//* FIXME */
+ return (char *)arg;
}
/*
@@ -55,7 +55,7 @@
unsigned char *
cast_to_unsigned_char_pointer(struct Other *arg)
{
- return (unsigned char *)arg; /* expect: 247 *//* FIXME */
+ return (unsigned char *)arg;
}
/*
diff -r 4f4ffa5253ba -r 484bbe1196ea tests/usr.bin/xlint/lint1/msg_247.exp
--- a/tests/usr.bin/xlint/lint1/msg_247.exp Fri Mar 26 16:53:19 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.exp Fri Mar 26 16:59:18 2021 +0000
@@ -1,4 +1,2 @@
msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct <unnamed>' may be troublesome [247]
-msg_247.c(48): warning: pointer cast from 'pointer to struct Other' to 'pointer to char' may be troublesome [247]
-msg_247.c(58): warning: pointer cast from 'pointer to struct Other' to 'pointer to unsigned char' 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]
diff -r 4f4ffa5253ba -r 484bbe1196ea usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Fri Mar 26 16:53:19 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Fri Mar 26 16:59:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.248 2021/03/26 16:53:19 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.249 2021/03/26 16:59:18 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.248 2021/03/26 16:53:19 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.249 2021/03/26 16:59:18 rillig Exp $");
#endif
#include <float.h>
@@ -2230,6 +2230,9 @@
if (tp->t_subt->t_str != tn->tn_type->t_subt->t_str)
return true;
+ if (nst == CHAR || nst == UCHAR)
+ return false; /* for the sake of traditional C code */
+
/*
* XXX: Why should it be ok to cast between arbitrary structs that
* just happen to be of the same size?
Home |
Main Index |
Thread Index |
Old Index