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: change return type of 'msb' from i...



details:   https://anonhg.NetBSD.org/src/rev/d97b6c469f3c
branches:  trunk
changeset: 1023029:d97b6c469f3c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Aug 19 21:13:58 2021 +0000

description:
lint: change return type of 'msb' from int to bool

No functional change.

diffstat:

 usr.bin/xlint/lint1/emit1.c    |  10 +++++-----
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/lex.c      |  14 +++++++-------
 usr.bin/xlint/lint1/tree.c     |  22 +++++++++++-----------
 4 files changed, 25 insertions(+), 25 deletions(-)

diffs (155 lines):

diff -r 69a1b6c35332 -r d97b6c469f3c usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Thu Aug 19 20:56:36 2021 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Thu Aug 19 21:13:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.48 2021/08/08 10:41:34 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.49 2021/08/19 21:13:58 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.48 2021/08/08 10:41:34 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.49 2021/08/19 21:13:58 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -415,11 +415,11 @@
                                if ((q = arg->tn_val->v_quad) == 0) {
                                        /* zero constant */
                                        outchar('z');
-                               } else if (msb(q, t, 0) == 0) {
-                                       /* positive if casted to signed */
+                               } else if (!msb(q, t, 0)) {
+                                       /* positive if cast to signed */
                                        outchar('p');
                                } else {
-                                       /* negative if casted to signed */
+                                       /* negative if cast to signed */
                                        outchar('n');
                                }
                                outint(n);
diff -r 69a1b6c35332 -r d97b6c469f3c usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Thu Aug 19 20:56:36 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Thu Aug 19 21:13:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.128 2021/08/01 19:11:54 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.129 2021/08/19 21:13:58 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -76,7 +76,7 @@
 extern FILE    *yyin;
 
 extern void    initscan(void);
-extern int     msb(int64_t, tspec_t, int);
+extern bool    msb(int64_t, tspec_t, int);
 extern int64_t convert_integer(int64_t, tspec_t, int);
 extern void    clear_warn_flags(void);
 extern sym_t   *getsym(sbuf_t *);
diff -r 69a1b6c35332 -r d97b6c469f3c usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Thu Aug 19 20:56:36 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Thu Aug 19 21:13:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.64 2021/08/19 20:08:25 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.65 2021/08/19 21:13:58 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.64 2021/08/19 20:08:25 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.65 2021/08/19 21:13:58 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -679,13 +679,13 @@
        return T_CON;
 }
 
-int
+bool
 msb(int64_t q, tspec_t t, int len)
 {
 
        if (len <= 0)
                len = size_in_bits(t);
-       return (q & bit(len - 1)) != 0 ? 1 : 0;
+       return (q & bit(len - 1)) != 0;
 }
 
 /*
@@ -703,9 +703,9 @@
                len = size_in_bits(t);
 
        vbits = value_bits(len);
-       return t == PTR || is_uinteger(t) || msb(q, t, len) == 0
-           ? q & vbits
-           : q | ~vbits;
+       return t == PTR || is_uinteger(t) || !msb(q, t, len)
+           ? (int64_t)(q & vbits)
+           : (int64_t)(q | ~vbits);
 }
 
 /*
diff -r 69a1b6c35332 -r d97b6c469f3c usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Aug 19 20:56:36 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Aug 19 21:13:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.339 2021/08/19 20:53:37 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.340 2021/08/19 21:13:58 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.339 2021/08/19 20:53:37 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.340 2021/08/19 21:13:58 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2010,7 +2010,7 @@
                 */
                if (ptn->tn_op == CON && is_integer(nt) &&
                    signed_type(nt) == signed_type(ot) &&
-                   msb(ptn->tn_val->v_quad, ot, -1) == 0) {
+                   !msb(ptn->tn_val->v_quad, ot, -1)) {
                        /* ok */
                } else {
                        /* argument #%d is converted from '%s' to '%s' ... */
@@ -3068,21 +3068,21 @@
                break;
        case PLUS:
                q = utyp ? (int64_t)(ul + ur) : sl + sr;
-               if (msb(sl, t, -1) != 0 && msb(sr, t, -1) != 0) {
-                       if (msb(q, t, -1) == 0)
+               if (msb(sl, t, -1) && msb(sr, t, -1)) {
+                       if (!msb(q, t, -1))
                                ovfl = true;
-               } else if (msb(sl, t, -1) == 0 && msb(sr, t, -1) == 0) {
-                       if (msb(q, t, -1) != 0 && !utyp)
+               } else if (!msb(sl, t, -1) && !msb(sr, t, -1)) {
+                       if (msb(q, t, -1) && !utyp)
                                ovfl = true;
                }
                break;
        case MINUS:
                q = utyp ? (int64_t)(ul - ur) : sl - sr;
-               if (msb(sl, t, -1) != 0 && msb(sr, t, -1) == 0) {
-                       if (msb(q, t, -1) == 0)
+               if (msb(sl, t, -1) && !msb(sr, t, -1)) {
+                       if (!msb(q, t, -1))
                                ovfl = true;
-               } else if (msb(sl, t, -1) == 0 && msb(sr, t, -1) != 0) {
-                       if (msb(q, t, -1) != 0)
+               } else if (!msb(sl, t, -1) && msb(sr, t, -1)) {
+                       if (msb(q, t, -1))
                                ovfl = true;
                }
                break;



Home | Main Index | Thread Index | Old Index