Module Name: src
Committed By: rillig
Date: Sun Aug 22 12:15:38 UTC 2021
Modified Files:
src/usr.bin/xlint/lint2: lint2.h read.c
Log Message:
lint: convert TP from macro to inline function
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint2/lint2.h
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/xlint/lint2/read.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint2/lint2.h
diff -u src/usr.bin/xlint/lint2/lint2.h:1.14 src/usr.bin/xlint/lint2/lint2.h:1.15
--- src/usr.bin/xlint/lint2/lint2.h:1.14 Sat Apr 10 18:36:27 2021
+++ src/usr.bin/xlint/lint2/lint2.h Sun Aug 22 12:15:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint2.h,v 1.14 2021/04/10 18:36:27 rillig Exp $ */
+/* $NetBSD: lint2.h,v 1.15 2021/08/22 12:15:37 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -185,7 +185,11 @@ typedef struct hte {
struct hte *h_hte; /* pointer to other htes (for renames) */
} hte_t;
-/* maps type indices into pointers to type structs */
-#define TP(idx) (tlst[idx])
-
#include "externs2.h"
+
+/* maps type indices into pointers to type structs */
+static inline type_t *
+TP(u_short type_id) {
+ /* force sequence point for newly parsed type_id */
+ return tlst[type_id];
+}
Index: src/usr.bin/xlint/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.50 src/usr.bin/xlint/lint2/read.c:1.51
--- src/usr.bin/xlint/lint2/read.c:1.50 Sun Aug 22 11:57:23 2021
+++ src/usr.bin/xlint/lint2/read.c Sun Aug 22 12:15:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.50 2021/08/22 11:57:23 rillig Exp $ */
+/* $NetBSD: read.c,v 1.51 2021/08/22 12:15:37 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: read.c,v 1.50 2021/08/22 11:57:23 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.51 2021/08/22 12:15:37 rillig Exp $");
#endif
#include <ctype.h>
@@ -625,7 +625,7 @@ inptype(const char *cp, const char **epp
int narg, i;
bool osdef = false;
size_t tlen;
- u_short tidx, sidx;
+ u_short tidx;
int h;
/* If we have this type already, return its index. */
@@ -657,12 +657,10 @@ inptype(const char *cp, const char **epp
switch (tp->t_tspec) {
case ARRAY:
tp->t_dim = parse_int(&cp);
- sidx = inptype(cp, &cp); /* force seq. point! (ditto below) */
- tp->t_subt = TP(sidx);
+ tp->t_subt = TP(inptype(cp, &cp));
break;
case PTR:
- sidx = inptype(cp, &cp);
- tp->t_subt = TP(sidx);
+ tp->t_subt = TP(inptype(cp, &cp));
break;
case FUNC:
c = *cp;
@@ -670,20 +668,18 @@ inptype(const char *cp, const char **epp
if (!osdef)
tp->t_proto = true;
narg = parse_int(&cp);
- tp->t_args = xcalloc((size_t)(narg + 1),
+ tp->t_args = xcalloc((size_t)narg + 1,
sizeof(*tp->t_args));
for (i = 0; i < narg; i++) {
if (i == narg - 1 && *cp == 'E') {
tp->t_vararg = true;
cp++;
} else {
- sidx = inptype(cp, &cp);
- tp->t_args[i] = TP(sidx);
+ tp->t_args[i] = TP(inptype(cp, &cp));
}
}
}
- sidx = inptype(cp, &cp);
- tp->t_subt = TP(sidx);
+ tp->t_subt = TP(inptype(cp, &cp));
break;
case ENUM:
tp->t_tspec = INT;
@@ -994,7 +990,7 @@ findtype(const char *cp, size_t len, int
}
/*
- * Store a type and its type string so we can later share this type
+ * Store a type and its type string, so we can later share this type
* if we read the same type string from the input file.
*/
static u_short