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: remove unnecessary width parameter...



details:   https://anonhg.NetBSD.org/src/rev/362782a10d29
branches:  trunk
changeset: 1023088:362782a10d29
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Aug 23 06:21:59 2021 +0000

description:
lint: remove unnecessary width parameter for msb

No functional change.

diffstat:

 usr.bin/xlint/lint1/emit1.c    |   6 +++---
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/lex.c      |  12 +++++-------
 usr.bin/xlint/lint1/tree.c     |  23 +++++++++++------------
 4 files changed, 21 insertions(+), 24 deletions(-)

diffs (159 lines):

diff -r 2b104a9d4c50 -r 362782a10d29 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Mon Aug 23 06:10:26 2021 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Mon Aug 23 06:21:59 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.49 2021/08/19 21:13:58 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.50 2021/08/23 06:21:59 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: emit1.c,v 1.49 2021/08/19 21:13:58 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.50 2021/08/23 06:21:59 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -415,7 +415,7 @@
                                if ((q = arg->tn_val->v_quad) == 0) {
                                        /* zero constant */
                                        outchar('z');
-                               } else if (!msb(q, t, 0)) {
+                               } else if (!msb(q, t)) {
                                        /* positive if cast to signed */
                                        outchar('p');
                                } else {
diff -r 2b104a9d4c50 -r 362782a10d29 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Mon Aug 23 06:10:26 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Mon Aug 23 06:21:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.130 2021/08/22 14:50:06 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.131 2021/08/23 06:21:59 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -78,7 +78,7 @@
 extern FILE    *yyin;
 
 extern void    initscan(void);
-extern bool    msb(int64_t, tspec_t, int);
+extern bool    msb(int64_t, tspec_t);
 extern int64_t convert_integer(int64_t, tspec_t, int);
 extern void    clear_warn_flags(void);
 extern sym_t   *getsym(sbuf_t *);
diff -r 2b104a9d4c50 -r 362782a10d29 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Mon Aug 23 06:10:26 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Mon Aug 23 06:21:59 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.67 2021/08/22 13:12:39 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.68 2021/08/23 06:21:59 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: lex.c,v 1.67 2021/08/22 13:12:39 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.68 2021/08/23 06:21:59 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -673,12 +673,10 @@
 }
 
 bool
-msb(int64_t q, tspec_t t, int len)
+msb(int64_t q, tspec_t t)
 {
 
-       if (len <= 0)
-               len = size_in_bits(t);
-       return (q & bit(len - 1)) != 0;
+       return (q & bit(size_in_bits(t) - 1)) != 0;
 }
 
 /*
@@ -696,7 +694,7 @@
                len = size_in_bits(t);
 
        vbits = value_bits(len);
-       return t == PTR || is_uinteger(t) || !msb(q, t, len)
+       return t == PTR || is_uinteger(t) || ((q & bit(len - 1)) == 0)
            ? (int64_t)(q & vbits)
            : (int64_t)(q | ~vbits);
 }
diff -r 2b104a9d4c50 -r 362782a10d29 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Aug 23 06:10:26 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Aug 23 06:21:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.347 2021/08/23 06:10:26 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.348 2021/08/23 06:21:59 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.347 2021/08/23 06:10:26 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.348 2021/08/23 06:21:59 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1979,7 +1979,7 @@
         */
        if (ptn->tn_op == CON && is_integer(nt) &&
            signed_type(nt) == signed_type(ot) &&
-           !msb(ptn->tn_val->v_quad, ot, -1))
+           !msb(ptn->tn_val->v_quad, ot))
                return;
 
        /* argument #%d is converted from '%s' to '%s' ... */
@@ -3045,7 +3045,7 @@
                break;
        case UMINUS:
                q = -sl;
-               if (sl != 0 && msb(q, t, -1) == msb(sl, t, -1))
+               if (sl != 0 && msb(q, t) == msb(sl, t))
                        ovfl = true;
                break;
        case COMPL:
@@ -3060,7 +3060,7 @@
                                ovfl = true;
                } else {
                        q = sl * sr;
-                       if (msb(q, t, -1) != (msb(sl, t, -1) ^ msb(sr, t, -1)))
+                       if (msb(q, t) != (msb(sl, t) ^ msb(sr, t)))
                                ovfl = true;
                }
                break;
@@ -3084,20 +3084,19 @@
                break;
        case PLUS:
                q = utyp ? (int64_t)(ul + ur) : sl + sr;
-               if (msb(sl, t, -1) && msb(sr, t, -1)) {
-                       if (!msb(q, t, -1))
+               if (msb(sl, t) && msb(sr, t)) {
+                       if (!msb(q, t))
                                ovfl = true;
-               } else if (!msb(sl, t, -1) && !msb(sr, t, -1)) {
-                       if (msb(q, t, -1) && !utyp)
+               } else if (!msb(sl, t) && !msb(sr, t)) {
+                       if (msb(q, t) && !utyp)
                                ovfl = true;
                }
                break;
        case MINUS:
                q = utyp ? (int64_t)(ul - ur) : sl - sr;
-               if (!utyp &&
-                   msb(sl, t, -1) && !msb(sr, t, -1) && !msb(q, t, -1))
+               if (!utyp && msb(sl, t) && !msb(sr, t) && !msb(q, t))
                        ovfl = true;
-               if (!msb(sl, t, -1) && msb(sr, t, -1) && msb(q, t, -1))
+               if (!msb(sl, t) && msb(sr, t) && msb(q, t))
                        ovfl = true;
                break;
        case SHL:



Home | Main Index | Thread Index | Old Index