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 simplify.



details:   https://anonhg.NetBSD.org/src/rev/d705fbb07dcd
branches:  trunk
changeset: 1024734:d705fbb07dcd
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Nov 01 13:30:11 2021 +0000

description:
simplify.

diffstat:

 usr.bin/xlint/lint1/tree.c |  33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)

diffs (73 lines):

diff -r 20fc4377d331 -r d705fbb07dcd usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Nov 01 12:26:18 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Nov 01 13:30:11 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.389 2021/11/01 11:46:50 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.390 2021/11/01 13:30:11 christos 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.389 2021/11/01 11:46:50 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.390 2021/11/01 13:30:11 christos Exp $");
 #endif
 
 #include <float.h>
@@ -1779,23 +1779,23 @@
        int max_array_index;
        int64_t max_enum_value;
        const struct sym *ec, *max_ec;
-
-       if (ln->tn_op != ADDR)
+       const type_t *lt, *rt;
+
+       if (ln->tn_op != ADDR || ln->tn_left->tn_op != NAME)
                return;
-       if (ln->tn_left->tn_op != NAME)
-               return;
-       if (ln->tn_left->tn_type->t_tspec != ARRAY)
-               return;
-       if (ln->tn_left->tn_type->t_incomplete_array)
+
+       lt = ln->tn_left->tn_type;
+       if (lt->t_tspec != ARRAY || lt->t_incomplete_array)
                return;
-       if (rn->tn_op != CVT)
-               return;
-       if (rn->tn_left->tn_op != LOAD)
+
+       if (rn->tn_op != CVT || rn->tn_left->tn_op != LOAD)
                return;
-       if (rn->tn_left->tn_type->t_tspec != ENUM)
+
+       rt = rn->tn_left->tn_type;
+       if (rt->t_tspec != ENUM)
                return;
 
-       ec = rn->tn_left->tn_type->t_enum->en_first_enumerator;
+       ec = rt->t_enum->en_first_enumerator;
        max_ec = ec;
        lint_assert(ec != NULL);
        for (ec = ec->s_next; ec != NULL; ec = ec->s_next)
@@ -1805,7 +1805,7 @@
        max_enum_value = max_ec->s_value.v_quad;
        lint_assert(INT_MIN <= max_enum_value && max_enum_value <= INT_MAX);
 
-       max_array_index = ln->tn_left->tn_type->t_dim - 1;
+       max_array_index = lt->t_dim - 1;
        if (max_enum_value == max_array_index)
                return;
 
@@ -1820,8 +1820,7 @@
                return;
 
        /* maximum value %d of '%s' does not match maximum array index %d */
-       warning(348, (int)max_enum_value, type_name(rn->tn_left->tn_type),
-           max_array_index);
+       warning(348, (int)max_enum_value, type_name(rt), max_array_index);
        print_previous_declaration(-1, max_ec);
 }
 



Home | Main Index | Thread Index | Old Index