Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint2 lint: convert TP from macro to inline fu...



details:   https://anonhg.NetBSD.org/src/rev/b24ac338e53f
branches:  trunk
changeset: 985387:b24ac338e53f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 22 12:15:37 2021 +0000

description:
lint: convert TP from macro to inline function

No functional change.

diffstat:

 usr.bin/xlint/lint2/lint2.h |  12 ++++++++----
 usr.bin/xlint/lint2/read.c  |  22 +++++++++-------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diffs (99 lines):

diff -r 1eb49f214c7a -r b24ac338e53f usr.bin/xlint/lint2/lint2.h
--- a/usr.bin/xlint/lint2/lint2.h       Sun Aug 22 11:57:23 2021 +0000
+++ b/usr.bin/xlint/lint2/lint2.h       Sun Aug 22 12:15:37 2021 +0000
@@ -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 @@
        struct  hte *h_hte;     /* pointer to other htes (for renames) */
 } hte_t;
 
+#include "externs2.h"
+
 /* maps type indices into pointers to type structs */
-#define TP(idx)                (tlst[idx])
-
-#include "externs2.h"
+static inline type_t *
+TP(u_short type_id) {
+       /* force sequence point for newly parsed type_id */
+       return tlst[type_id];
+}
diff -r 1eb49f214c7a -r b24ac338e53f usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Sun Aug 22 11:57:23 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Sun Aug 22 12:15:37 2021 +0000
@@ -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 @@
        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 @@
        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 @@
                        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 @@
 }
 
 /*
- * 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



Home | Main Index | Thread Index | Old Index