Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint lint: use unsigned integers for storing hash v...



details:   https://anonhg.NetBSD.org/src/rev/52fa02ad2868
branches:  trunk
changeset: 1023070:52fa02ad2868
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 22 13:12:39 2021 +0000

description:
lint: use unsigned integers for storing hash values

The computation of the hash values is unchanged, only the resulting
value (which is always less than 1009 anyway, see HSHSIZ2) is stored as
unsigned as well.

No functional change.

diffstat:

 usr.bin/xlint/lint1/lex.c  |  12 ++++++------
 usr.bin/xlint/lint2/hash.c |  10 +++++-----
 usr.bin/xlint/lint2/read.c |   6 +++---
 3 files changed, 14 insertions(+), 14 deletions(-)

diffs (126 lines):

diff -r b0912c53a713 -r 52fa02ad2868 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Aug 22 13:01:47 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Aug 22 13:12:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.66 2021/08/22 13:01:47 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.67 2021/08/22 13:12:39 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.66 2021/08/22 13:01:47 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.67 2021/08/22 13:12:39 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -72,7 +72,7 @@
 static sbuf_t *allocsb(void);
 static void    freesb(sbuf_t *);
 static int     inpc(void);
-static int     hash(const char *);
+static u_int   hash(const char *);
 static sym_t * search(sbuf_t *);
 static int     keyw(sym_t *);
 static int     get_escaped_char(int);
@@ -316,7 +316,7 @@
 
 /*
  * All keywords are written to the symbol table. This saves us looking
- * in a extra table for each name we found.
+ * in an extra table for each name we found.
  */
 void
 initscan(void)
@@ -392,7 +392,7 @@
        return c;
 }
 
-static int
+static u_int
 hash(const char *s)
 {
        u_int   v;
@@ -459,7 +459,7 @@
 static sym_t *
 search(sbuf_t *sb)
 {
-       int h;
+       u_int h;
        sym_t *sym;
        const struct kwtab *kw;
 
diff -r b0912c53a713 -r 52fa02ad2868 usr.bin/xlint/lint2/hash.c
--- a/usr.bin/xlint/lint2/hash.c        Sun Aug 22 13:01:47 2021 +0000
+++ b/usr.bin/xlint/lint2/hash.c        Sun Aug 22 13:12:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.15 2021/04/02 12:16:50 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.16 2021/08/22 13:12:39 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: hash.c,v 1.15 2021/04/02 12:16:50 rillig Exp $");
+__RCSID("$NetBSD: hash.c,v 1.16 2021/08/22 13:12:39 rillig Exp $");
 #endif
 
 /*
@@ -54,7 +54,7 @@
 /* pointer to hash table, initialized in inithash() */
 static hte_t   **htab;
 
-static int     hash(const char *);
+static u_int   hash(const char *);
 
 /*
  * Initialize hash table.
@@ -72,7 +72,7 @@
 /*
  * Compute hash value from a string.
  */
-static int
+static u_int
 hash(const char *s)
 {
        u_int   v;
@@ -93,7 +93,7 @@
 hte_t *
 _hsearch(hte_t **table, const char *s, bool mknew)
 {
-       int     h;
+       u_int   h;
        hte_t   *hte;
 
        if (table == NULL)
diff -r b0912c53a713 -r 52fa02ad2868 usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Sun Aug 22 13:01:47 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Sun Aug 22 13:12:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.53 2021/08/22 12:32:13 rillig Exp $ */
+/* $NetBSD: read.c,v 1.54 2021/08/22 13:12:39 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: read.c,v 1.53 2021/08/22 12:32:13 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.54 2021/08/22 13:12:39 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1159,7 +1159,7 @@
         * Create a new hash table entry
         *
         * XXX this entry should be put at the beginning of the list to
-        * avoid to process the same symbol twice.
+        * avoid processing the same symbol twice.
         */
        for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link)
                continue;



Home | Main Index | Thread Index | Old Index