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: let gnuism and c99ism return void ...
details: https://anonhg.NetBSD.org/src/rev/17338e4a3989
branches: trunk
changeset: 949166:17338e4a3989
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 03 17:42:45 2021 +0000
description:
lint: let gnuism and c99ism return void instead of int
The return value was only used in a single case. Duplicating the
condition for printing a message is ok in that case, since it makes all
other places in the code simpler.
The occasional "(void)" or "msg = " before the function call had hidden
the calls from check-msgs.lua, which didn't check the message texts in
such cases.
diffstat:
usr.bin/xlint/lint1/decl.c | 13 +++++++------
usr.bin/xlint/lint1/err.c | 29 ++++++++---------------------
usr.bin/xlint/lint1/externs1.h | 6 +++---
usr.bin/xlint/lint1/init.c | 6 +++---
usr.bin/xlint/lint1/scan.l | 8 ++++----
usr.bin/xlint/lint1/tree.c | 10 +++++-----
6 files changed, 30 insertions(+), 42 deletions(-)
diffs (233 lines):
diff -r 7ca95b207b88 -r 17338e4a3989 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun Jan 03 17:42:10 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun Jan 03 17:42:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.105 2021/01/03 17:11:19 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.106 2021/01/03 17:42:45 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.105 2021/01/03 17:11:19 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.106 2021/01/03 17:42:45 rillig Exp $");
#endif
#include <sys/param.h>
@@ -317,7 +317,7 @@
dcs->d_lmod = NOTSPEC;
if (!quadflg)
/* %s C does not support 'long long' */
- (void)c99ism(265, tflag ? "traditional" : "c89");
+ c99ism(265, tflag ? "traditional" : "c89");
}
if (dcs->d_type != NULL && dcs->d_type->t_typedef) {
@@ -1778,8 +1778,8 @@
sp->size = dcs->d_offset;
if (sp->size == 0) {
- /* zero sized %s */
- (void)c99ism(47, ttab[t].tt_name);
+ /* zero sized %s is a C9X feature */
+ c99ism(47, ttab[t].tt_name);
}
n = 0;
@@ -2531,7 +2531,8 @@
if (!eqtype(tp, ptp, 1, 1, &dowarn)) {
if (eqtype(tp, ptp, 1, 0, &dowarn)) {
/* type does not match prototype: %s */
- msg = gnuism(58, arg->s_name);
+ gnuism(58, arg->s_name);
+ msg = sflag || !gflag;
} else {
/* type does not match prototype: %s */
error(58, arg->s_name);
diff -r 7ca95b207b88 -r 17338e4a3989 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Jan 03 17:42:10 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Jan 03 17:42:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.62 2021/01/03 16:59:59 rillig Exp $ */
+/* $NetBSD: err.c,v 1.63 2021/01/03 17:42:45 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.62 2021/01/03 16:59:59 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.63 2021/01/03 17:42:45 rillig Exp $");
#endif
#include <sys/types.h>
@@ -534,44 +534,31 @@
* forward? We need to answer that and then we can fix this to be
* "right"... [perry, 2 Nov 2002]
*/
-int
+void
c99ism(int n, ...)
{
va_list ap;
- int msg;
+ bool extensions_ok = Sflag || gflag;
va_start(ap, n);
- if (sflag && !(Sflag || gflag)) {
+ if (sflag && !extensions_ok) {
verror(n, ap);
- msg = 1;
- } else if (!sflag && (Sflag || gflag)) {
- msg = 0;
- } else {
+ } else if (sflag || !extensions_ok) {
vwarning(n, ap);
- msg = 1;
}
va_end(ap);
-
- return msg;
}
-int
+void
gnuism(int n, ...)
{
va_list ap;
- int msg;
va_start(ap, n);
if (sflag && !gflag) {
verror(n, ap);
- msg = 1;
- } else if (!sflag && gflag) {
- msg = 0;
- } else {
+ } else if (sflag || !gflag) {
vwarning(n, ap);
- msg = 1;
}
va_end(ap);
-
- return msg;
}
diff -r 7ca95b207b88 -r 17338e4a3989 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sun Jan 03 17:42:10 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sun Jan 03 17:42:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.44 2021/01/02 18:44:58 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.45 2021/01/03 17:42:45 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -123,8 +123,8 @@
extern void error(int, ...);
extern void warning(int, ...);
extern void message(int, ...);
-extern int gnuism(int, ...);
-extern int c99ism(int, ...);
+extern void gnuism(int, ...);
+extern void c99ism(int, ...);
extern void lerror(const char *, int, const char *, ...)
__attribute__((__noreturn__,__format__(__printf__, 3, 4)));
extern void assert_failed(const char *, int, const char *, const char *)
diff -r 7ca95b207b88 -r 17338e4a3989 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sun Jan 03 17:42:10 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sun Jan 03 17:42:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.57 2021/01/02 03:49:25 rillig Exp $ */
+/* $NetBSD: init.c,v 1.58 2021/01/03 17:42:45 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.57 2021/01/02 03:49:25 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.58 2021/01/03 17:42:45 rillig Exp $");
#endif
#include <stdlib.h>
@@ -652,7 +652,7 @@
if (conaddr(tn, &sym, &offs) == -1) {
if (sc == AUTO || sc == REG) {
/* non-constant initializer */
- (void)c99ism(177);
+ c99ism(177);
} else {
/* non-constant initializer */
error(177);
diff -r 7ca95b207b88 -r 17338e4a3989 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l Sun Jan 03 17:42:10 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l Sun Jan 03 17:42:45 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.111 2021/01/03 17:42:45 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.111 2021/01/03 17:42:45 rillig Exp $");
#endif
#include <ctype.h>
@@ -1316,8 +1316,8 @@
int c;
if (!Sflag && !gflag)
- /* // comments only supported in C99 */
- (void)gnuism(312, tflag ? "traditional" : "ANSI");
+ /* %s C does not support // comments */
+ gnuism(312, tflag ? "traditional" : "ANSI");
while ((c = inpc()) != EOF && c != '\n')
continue;
diff -r 7ca95b207b88 -r 17338e4a3989 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Jan 03 17:42:10 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Jan 03 17:42:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.117 2021/01/03 15:51:16 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.118 2021/01/03 17:42:45 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.117 2021/01/03 15:51:16 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.118 2021/01/03 17:42:45 rillig Exp $");
#endif
#include <float.h>
@@ -660,9 +660,9 @@
*/
if (tn->tn_type->t_tspec == ARRAY) {
if (!tn->tn_lvalue) {
+ /* XXX print correct operator */
/* %soperand of '%s' must be lvalue */
- /* XXX print correct operator */
- (void)gnuism(114, "", modtab[AMPER].m_name);
+ gnuism(114, "", modtab[AMPER].m_name);
}
tn = new_tnode(AMPER, tincref(tn->tn_type->t_subt, PTR),
tn, NULL);
@@ -2631,7 +2631,7 @@
break;
case VOID:
/* cannot do pointer arithmetic on operand of ... */
- (void)gnuism(136);
+ gnuism(136);
break;
case STRUCT:
case UNION:
Home |
Main Index |
Thread Index |
Old Index