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: inline 'sign' into convert_integer



details:   https://anonhg.NetBSD.org/src/rev/a0d2b531c383
branches:  trunk
changeset: 984277:a0d2b531c383
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 30 10:25:02 2021 +0000

description:
lint: inline 'sign' into convert_integer

No functional change.

diffstat:

 usr.bin/xlint/lint1/lex.c |  24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)

diffs (59 lines):

diff -r 9dfa5ac57b73 -r a0d2b531c383 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Wed Jun 30 07:36:05 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Wed Jun 30 10:25:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.49 2021/06/29 21:16:54 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.50 2021/06/30 10:25:02 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.49 2021/06/29 21:16:54 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.50 2021/06/30 10:25:02 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -678,21 +678,6 @@
        return T_CON;
 }
 
-/*
- * Returns whether t is a signed type and the value is negative.
- *
- * len is the number of significant bits. If len is -1, len is set
- * to the width of type t.
- */
-static bool
-sign(int64_t q, tspec_t t, int len)
-{
-
-       if (t == PTR || is_uinteger(t))
-               return false;
-       return msb(q, t, len) != 0;
-}
-
 int
 msb(int64_t q, tspec_t t, int len)
 {
@@ -704,6 +689,9 @@
 
 /*
  * Extend or truncate q to match t.  If t is signed, sign-extend.
+ *
+ * len is the number of significant bits. If len is -1, len is set
+ * to the width of type t.
  */
 int64_t
 convert_integer(int64_t q, tspec_t t, int len)
@@ -714,7 +702,7 @@
                len = size_in_bits(t);
 
        vbits = value_bits(len);
-       return t == PTR || is_uinteger(t) || !sign(q, t, len)
+       return t == PTR || is_uinteger(t) || msb(q, t, len) == 0
            ? q & vbits
            : q | ~vbits;
 }



Home | Main Index | Thread Index | Old Index