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: fix confusing message about nonpor...
details: https://anonhg.NetBSD.org/src/rev/f08f071e3f5a
branches: trunk
changeset: 373645:f08f071e3f5a
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Feb 22 22:30:40 2023 +0000
description:
lint: fix confusing message about nonportable character constants
diffstat:
tests/usr.bin/xlint/lint1/msg_230.c | 16 ++++++++--------
tests/usr.bin/xlint/lint1/msg_230_uchar.c | 16 ++++++++--------
tests/usr.bin/xlint/lint1/platform_schar.c | 5 ++---
usr.bin/xlint/lint1/err.c | 6 +++---
usr.bin/xlint/lint1/tree.c | 18 ++++++++++++------
5 files changed, 33 insertions(+), 28 deletions(-)
diffs (178 lines):
diff -r c16e68d323e1 -r f08f071e3f5a tests/usr.bin/xlint/lint1/msg_230.c
--- a/tests/usr.bin/xlint/lint1/msg_230.c Wed Feb 22 22:12:35 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230.c Wed Feb 22 22:30:40 2023 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_230.c,v 1.11 2022/02/26 11:13:01 rillig Exp $ */
+/* $NetBSD: msg_230.c,v 1.12 2023/02/22 22:30:40 rillig Exp $ */
# 3 "msg_230.c"
-// Test for message: nonportable character comparison '%s %d' [230]
+// Test for message: nonportable character comparison '%s' [230]
/* lint1-flags: -S -g -p -w */
/* lint1-only-if: schar */
@@ -46,26 +46,26 @@
void
compare_plain_char_yoda(char c)
{
- /* expect+1: warning: nonportable character comparison '== -129' [230] */
+ /* expect+1: warning: nonportable character comparison '-129 == ?' [230] */
if (-129 == c)
return;
- /* expect+1: warning: nonportable character comparison '== -128' [230] */
+ /* expect+1: warning: nonportable character comparison '-128 == ?' [230] */
if (-128 == c)
return;
- /* expect+1: warning: nonportable character comparison '== -1' [230] */
+ /* expect+1: warning: nonportable character comparison '-1 == ?' [230] */
if (-1 == c)
return;
if (0 == c)
return;
if (127 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 128' [230] */
+ /* expect+1: warning: nonportable character comparison '128 == ?' [230] */
if (128 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 255' [230] */
+ /* expect+1: warning: nonportable character comparison '255 == ?' [230] */
if (255 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 256' [230] */
+ /* expect+1: warning: nonportable character comparison '256 == ?' [230] */
if (256 == c)
return;
}
diff -r c16e68d323e1 -r f08f071e3f5a tests/usr.bin/xlint/lint1/msg_230_uchar.c
--- a/tests/usr.bin/xlint/lint1/msg_230_uchar.c Wed Feb 22 22:12:35 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230_uchar.c Wed Feb 22 22:30:40 2023 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_230_uchar.c,v 1.9 2022/06/22 19:23:18 rillig Exp $ */
+/* $NetBSD: msg_230_uchar.c,v 1.10 2023/02/22 22:30:40 rillig Exp $ */
# 3 "msg_230_uchar.c"
-// Test for message: nonportable character comparison '%s %d' [230]
+// Test for message: nonportable character comparison '%s' [230]
/* lint1-flags: -S -g -p -w */
/* lint1-only-if: uchar */
@@ -46,26 +46,26 @@
void
compare_plain_char_yoda(char c)
{
- /* expect+1: warning: nonportable character comparison '== -129' [230] */
+ /* expect+1: warning: nonportable character comparison '? == -129' [230] */
if (-129 == c)
return;
- /* expect+1: warning: nonportable character comparison '== -128' [230] */
+ /* expect+1: warning: nonportable character comparison '? == -128' [230] */
if (-128 == c)
return;
- /* expect+1: warning: nonportable character comparison '== -1' [230] */
+ /* expect+1: warning: nonportable character comparison '? == -1' [230] */
if (-1 == c)
return;
if (0 == c)
return;
if (127 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 128' [230] */
+ /* expect+1: warning: nonportable character comparison '? == 128' [230] */
if (128 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 255' [230] */
+ /* expect+1: warning: nonportable character comparison '? == 255' [230] */
if (255 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 256' [230] */
+ /* expect+1: warning: nonportable character comparison '? == 256' [230] */
if (256 == c)
return;
}
diff -r c16e68d323e1 -r f08f071e3f5a tests/usr.bin/xlint/lint1/platform_schar.c
--- a/tests/usr.bin/xlint/lint1/platform_schar.c Wed Feb 22 22:12:35 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_schar.c Wed Feb 22 22:30:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_schar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
+/* $NetBSD: platform_schar.c,v 1.4 2023/02/22 22:30:40 rillig Exp $ */
# 3 "platform_schar.c"
/*
@@ -10,6 +10,5 @@
/* lint1-only-if: schar */
/* CONSTCOND */
-/* FIXME: Wrong order in the diagnostic, should be '-128 <' instead. */
-/* expect+1: warning: nonportable character comparison '< -128' [230] */
+/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
typedef int is_signed[(char)'\200' < (char)'\177' ? 1 : -1];
diff -r c16e68d323e1 -r f08f071e3f5a usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Wed Feb 22 22:12:35 2023 +0000
+++ b/usr.bin/xlint/lint1/err.c Wed Feb 22 22:30:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.188 2023/02/19 19:27:01 rillig Exp $ */
+/* $NetBSD: err.c,v 1.189 2023/02/22 22:30:40 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.188 2023/02/19 19:27:01 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.189 2023/02/22 22:30:40 rillig Exp $");
#endif
#include <limits.h>
@@ -285,7 +285,7 @@
"const object '%s' should have initializer", /* 227 */
"function cannot return const or volatile object", /* 228 */
"converting '%s' to '%s' is questionable", /* 229 */
- "nonportable character comparison '%s %d'", /* 230 */
+ "nonportable character comparison '%s'", /* 230 */
"argument '%s' unused in function '%s'", /* 231 */
"label '%s' unused in function '%s'", /* 232 */
"struct '%s' never defined", /* 233 */
diff -r c16e68d323e1 -r f08f071e3f5a usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Wed Feb 22 22:12:35 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c Wed Feb 22 22:30:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.504 2023/01/29 18:16:48 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.505 2023/02/22 22:30:40 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.504 2023/01/29 18:16:48 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.505 2023/02/22 22:30:40 rillig Exp $");
#endif
#include <float.h>
@@ -4634,13 +4634,19 @@
if (hflag || pflag) {
if (lt == CHAR && is_out_of_char_range(rn)) {
- /* nonportable character comparison '%s %d' */
- warning(230, op_name(op), (int)rn->tn_val->v_quad);
+ char buf[128];
+ (void)snprintf(buf, sizeof(buf), "%s %d",
+ op_name(op), (int)rn->tn_val->v_quad);
+ /* nonportable character comparison '%s' */
+ warning(230, buf);
return;
}
if (rt == CHAR && is_out_of_char_range(ln)) {
- /* nonportable character comparison '%s %d' */
- warning(230, op_name(op), (int)ln->tn_val->v_quad);
+ char buf[128];
+ (void)snprintf(buf, sizeof(buf), "%d %s ?",
+ (int)ln->tn_val->v_quad, op_name(op));
+ /* nonportable character comparison '%s' */
+ warning(230, buf);
return;
}
}
Home |
Main Index |
Thread Index |
Old Index