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: clean up typeok_eq and check_point...



details:   https://anonhg.NetBSD.org/src/rev/9db2e7301888
branches:  trunk
changeset: 1018143:9db2e7301888
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 24 10:55:11 2021 +0000

description:
lint: clean up typeok_eq and check_pointer_comparison

Since typeok_eq does not issue any diagnostics, prefix it with "is_".

By convention, the variable rt aliases rn->tn_type->t_tspec.  Make it
obvious that in check_pointer_comparison, rt corresponds to the subtype
of the pointer.

diffstat:

 usr.bin/xlint/lint1/tree.c |  26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diffs (71 lines):

diff -r 1067c8c89b85 -r 9db2e7301888 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jan 24 10:50:42 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jan 24 10:55:11 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.187 2021/01/24 10:55:11 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.186 2021/01/24 10:50:42 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.187 2021/01/24 10:55:11 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -950,7 +950,7 @@
 }
 
 static bool
-typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
+is_typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
        /* FIXME: missing tn_subt */
        if (lt == PTR && ((rt == PTR && rn->tn_type->t_tspec == VOID) ||
@@ -1358,7 +1358,7 @@
                 * Accept some things which are allowed with EQ and NE,
                 * but not with ordered comparisons.
                 */
-               if (typeok_eq(ln, lt, rn, rt))
+               if (is_typeok_eq(ln, lt, rn, rt))
                        break;
                /* FALLTHROUGH */
        case LT:
@@ -1502,17 +1502,17 @@
 check_pointer_comparison(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
        type_t  *ltp, *rtp;
-       tspec_t lt, rt;
+       tspec_t lst, rst;
        const   char *lts, *rts;
 
-       lt = (ltp = ln->tn_type)->t_subt->t_tspec;
-       rt = (rtp = rn->tn_type)->t_subt->t_tspec;
-
-       if (lt == VOID || rt == VOID) {
-               if (sflag && (lt == FUNC || rt == FUNC)) {
+       lst = (ltp = ln->tn_type)->t_subt->t_tspec;
+       rst = (rtp = rn->tn_type)->t_subt->t_tspec;
+
+       if (lst == VOID || rst == VOID) {
+               if (sflag && (lst == FUNC || rst == FUNC)) {
                        /* (void *)0 already handled in typeok() */
-                       *(lt == FUNC ? &lts : &rts) = "function pointer";
-                       *(lt == VOID ? &lts : &rts) = "'void *'";
+                       *(lst == FUNC ? &lts : &rts) = "function pointer";
+                       *(lst == VOID ? &lts : &rts) = "'void *'";
                        /* ANSI C forbids comparison of %s with %s */
                        warning(274, lts, rts);
                }
@@ -1524,7 +1524,7 @@
                return;
        }
 
-       if (lt == FUNC && rt == FUNC) {
+       if (lst == FUNC && rst == FUNC) {
                if (sflag && op != EQ && op != NE)
                        /* ANSI C forbids ordered comparisons of ... */
                        warning(125);



Home | Main Index | Thread Index | Old Index