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: make code simpler



details:   https://anonhg.NetBSD.org/src/rev/14b45c83f409
branches:  trunk
changeset: 374725:14b45c83f409
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed May 10 21:46:26 2023 +0000

description:
lint: make code simpler

No functional change.

diffstat:

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

diffs (52 lines):

diff -r c3e4fc7639ab -r 14b45c83f409 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Wed May 10 21:30:50 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Wed May 10 21:46:26 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.521 2023/05/09 15:51:33 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.522 2023/05/10 21:46:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.521 2023/05/09 15:51:33 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.522 2023/05/10 21:46:26 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -81,6 +81,7 @@ str_endswith(const char *haystack, const
        return nlen <= hlen &&
               memcmp(haystack + hlen - nlen, needle, nlen) == 0;
 }
+
 static const char *
 op_name(op_t op)
 {
@@ -98,9 +99,7 @@ width_in_bits(const type_t *tp)
 static bool
 ic_maybe_signed(const type_t *tp, const integer_constraints *ic)
 {
-
-       return !is_uinteger(tp->t_tspec) &&
-           (ic->bclr & ((uint64_t)1 << 63)) == 0;
+       return !is_uinteger(tp->t_tspec) && ic->bclr >> 63 == 0;
 }
 
 static integer_constraints
@@ -4486,11 +4485,9 @@ check_array_index(tnode_t *tn, bool ampe
        elsz /= CHAR_SIZE;
 
        /* Change the unit of the index from bytes to element size. */
-       int64_t con;
-       if (is_uinteger(rn->tn_type->t_tspec))
-               con = (uint64_t)rn->tn_val->v_quad / elsz;
-       else
-               con = rn->tn_val->v_quad / elsz;
+       int64_t con = is_uinteger(rn->tn_type->t_tspec)
+           ? (int64_t)((uint64_t)rn->tn_val->v_quad / elsz)
+           : rn->tn_val->v_quad / elsz;
 
        int dim = ln->tn_left->tn_type->t_dim + (amper ? 1 : 0);
 



Home | Main Index | Thread Index | Old Index