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: use 'unsigned int' for bit-size of...



details:   https://anonhg.NetBSD.org/src/rev/c8af0a6c0d3a
branches:  trunk
changeset: 985489:c8af0a6c0d3a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 28 13:11:10 2021 +0000

description:
lint: use 'unsigned int' for bit-size of types in convert_integer

There was no need to have two separate magic values (0 and -1) to mean
the same.

No functional change.

diffstat:

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

diffs (104 lines):

diff -r 92312c49681e -r c8af0a6c0d3a usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Sat Aug 28 13:02:25 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Sat Aug 28 13:11:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.134 2021/08/28 12:59:25 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.135 2021/08/28 13:11:10 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -78,7 +78,7 @@
 extern FILE    *yyin;
 
 extern void    initscan(void);
-extern int64_t convert_integer(int64_t, tspec_t, int);
+extern int64_t convert_integer(int64_t, tspec_t, unsigned int);
 extern void    clear_warn_flags(void);
 extern sym_t   *getsym(sbuf_t *);
 extern void    cleanup(void);
diff -r 92312c49681e -r c8af0a6c0d3a usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Aug 28 13:02:25 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Aug 28 13:11:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.71 2021/08/28 12:21:53 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.72 2021/08/28 13:11:10 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.71 2021/08/28 12:21:53 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.72 2021/08/28 13:11:10 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -52,7 +52,7 @@
 #include "lint1.h"
 #include "cgram.h"
 
-#define CHAR_MASK      ((int)(~(~0U << CHAR_SIZE)))
+#define CHAR_MASK      ((1U << CHAR_SIZE) - 1)
 
 
 /* Current position (it's also updated when an included file is parsed) */
@@ -504,7 +504,7 @@
 lex_integer_constant(const char *yytext, size_t yyleng, int base)
 {
        int     l_suffix, u_suffix;
-       int     len;
+       size_t  len;
        const   char *cp;
        char    c, *eptr;
        tspec_t typ;
@@ -663,7 +663,7 @@
                break;
        }
 
-       uq = (uint64_t)convert_integer((int64_t)uq, typ, -1);
+       uq = (uint64_t)convert_integer((int64_t)uq, typ, 0);
 
        yylval.y_val = xcalloc(1, sizeof(*yylval.y_val));
        yylval.y_val->v_tspec = typ;
@@ -680,11 +680,11 @@
  * to the width of type t.
  */
 int64_t
-convert_integer(int64_t q, tspec_t t, int len)
+convert_integer(int64_t q, tspec_t t, unsigned int len)
 {
        uint64_t vbits;
 
-       if (len <= 0)
+       if (len == 0)
                len = size_in_bits(t);
 
        vbits = value_bits(len);
diff -r 92312c49681e -r c8af0a6c0d3a usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Aug 28 13:02:25 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Aug 28 13:11:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.355 2021/08/28 12:59:25 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.356 2021/08/28 13:11:10 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.355 2021/08/28 12:59:25 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.356 2021/08/28 13:11:10 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3145,7 +3145,7 @@
                        warning(141, op_name(tn->tn_op));
        }
 
-       v->v_quad = convert_integer(q, t, -1);
+       v->v_quad = convert_integer(q, t, 0);
 
        cn = build_constant(tn->tn_type, v);
        if (tn->tn_left->tn_system_dependent)



Home | Main Index | Thread Index | Old Index