Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint2 lint: clean up lint2



details:   https://anonhg.NetBSD.org/src/rev/b60acb459f67
branches:  trunk
changeset: 377391:b60acb459f67
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jul 10 12:40:22 2023 +0000

description:
lint: clean up lint2

diffstat:

 usr.bin/xlint/lint2/chk.c      |   6 ++--
 usr.bin/xlint/lint2/externs2.h |  44 +++++++++++++++++++++---------------------
 usr.bin/xlint/lint2/hash.c     |  11 +++------
 usr.bin/xlint/lint2/lint2.h    |   3 +-
 usr.bin/xlint/lint2/main2.c    |  34 +++++++------------------------
 usr.bin/xlint/lint2/msg.c      |  14 +++++-------
 usr.bin/xlint/lint2/read.c     |  26 ++++++++++++------------
 7 files changed, 57 insertions(+), 81 deletions(-)

diffs (truncated from 365 to 300 lines):

diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/chk.c
--- a/usr.bin/xlint/lint2/chk.c Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/chk.c Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.57 2023/07/03 10:23:12 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.58 2023/07/10 12:40:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: chk.c,v 1.57 2023/07/03 10:23:12 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.58 2023/07/10 12:40:22 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -78,7 +78,7 @@ mark_main_as_used(void)
 {
        hte_t *hte;
 
-       if ((hte = hsearch("main", false)) != NULL)
+       if ((hte = htab_search("main", false)) != NULL)
                hte->h_used = true;
 }
 
diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/externs2.h
--- a/usr.bin/xlint/lint2/externs2.h    Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/externs2.h    Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs2.h,v 1.19 2023/01/14 08:48:18 rillig Exp $ */
+/* $NetBSD: externs2.h,v 1.20 2023/07/10 12:40:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,27 +35,27 @@
 /*
  * main2.c
  */
-extern bool    xflag;
-extern bool    uflag;
 extern bool    Cflag;
-extern const char *libname;
+extern bool    Fflag;
+extern bool    Hflag;
+extern bool    hflag;
 extern bool    sflag;
 extern bool    tflag;
-extern bool    Hflag;
-extern bool    hflag;
-extern bool    Fflag;
+extern bool    uflag;
+extern bool    xflag;
+extern const char *libname;
 
 /*
  * hash.c
  */
-extern hte_t** htab_new(void);
-extern hte_t   *_hsearch(hte_t **, const char *, bool);
-extern void    symtab_init(void);
-extern void    symtab_forall(void (*)(hte_t *));
-extern void    symtab_forall_sorted(void (*)(hte_t *));
-extern void    _destroyhash(hte_t **);
+hte_t**        htab_new(void);
+hte_t  *hash_search(hte_t **, const char *, bool);
+void   symtab_init(void);
+void   symtab_forall(void (*)(hte_t *));
+void   symtab_forall_sorted(void (*)(hte_t *));
+void   hash_free(hte_t **);
 
-#define        hsearch(a, b)   _hsearch(NULL, (a), (b))
+#define        htab_search(a, b)       hash_search(NULL, (a), (b))
 
 /*
  * read.c
@@ -63,23 +63,23 @@ extern      void    _destroyhash(hte_t **);
 extern const   char **fnames;
 extern type_t  **tlst;
 
-extern void    readfile(const char *);
-extern void    mkstatic(hte_t *);
+void   readfile(const char *);
+void   mkstatic(hte_t *);
 
 /*
  * chk.c
  */
-extern void    mark_main_as_used(void);
-extern void    check_name(const hte_t *);
+void   mark_main_as_used(void);
+void   check_name(const hte_t *);
 
 /*
  * msg.c
  */
-extern void    msg(int, ...);
-extern const   char *mkpos(pos_t *);
+void   msg(int, ...);
+const  char *mkpos(const pos_t *);
 
 /*
  * emit2.c
  */
-extern void    outlib(const char *);
-extern int     addoutfile(short);
+void   outlib(const char *);
+int    addoutfile(short);
diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/hash.c
--- a/usr.bin/xlint/lint2/hash.c        Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/hash.c        Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.26 2023/07/10 09:51:30 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.27 2023/07/10 12:40:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: hash.c,v 1.26 2023/07/10 09:51:30 rillig Exp $");
+__RCSID("$NetBSD: hash.c,v 1.27 2023/07/10 12:40:22 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -76,7 +76,7 @@ hash(const char *s)
  * given name exists and mknew is set, create a new one.
  */
 hte_t *
-_hsearch(hte_t **table, const char *s, bool mknew)
+hash_search(hte_t **table, const char *s, bool mknew)
 {
        unsigned int h;
        hte_t *hte;
@@ -185,14 +185,11 @@ symtab_forall_sorted(void (*action)(hte_
  * Free all contents of the hash table that this module allocated.
  */
 void
-_destroyhash(hte_t **table)
+hash_free(hte_t **table)
 {
        int i;
        hte_t *hte, *nexthte;
 
-       if (table == NULL)
-               err(1, "_destroyhash called on main hash table");
-
        for (i = 0; i < HTAB_BUCKETS; i++) {
                for (hte = table[i]; hte != NULL; hte = nexthte) {
                        free(__UNCONST(hte->h_name));
diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/lint2.h
--- a/usr.bin/xlint/lint2/lint2.h       Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/lint2.h       Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint2.h,v 1.22 2022/02/07 21:57:47 rillig Exp $ */
+/* $NetBSD: lint2.h,v 1.23 2023/07/10 12:40:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -120,7 +120,6 @@ typedef     struct sym {
                bool    s_printflike:1;
                bool    s_scanflike:1;
                unsigned short s_type;
-               /* XXX: gap of 4 bytes on LP64 platforms */
                struct  sym *s_next;    /* next symbol with same name */
        } s_s;
        /*
diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/main2.c
--- a/usr.bin/xlint/lint2/main2.c       Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/main2.c       Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main2.c,v 1.31 2023/07/03 11:16:32 rillig Exp $        */
+/*     $NetBSD: main2.c,v 1.32 2023/07/10 12:40:22 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: main2.c,v 1.31 2023/07/03 11:16:32 rillig Exp $");
+__RCSID("$NetBSD: main2.c,v 1.32 2023/07/10 12:40:22 rillig Exp $");
 #endif
 
 #include <stdio.h>
@@ -47,33 +47,15 @@
 
 #include "lint2.h"
 
-/* warnings for symbols which are declared but not defined or used */
-bool   xflag;
-
-bool   uflag;
-
-/* Create a lint library in the current directory with name libname. */
 bool   Cflag;
-const char *libname;
-
-/*
- * warnings for (tentative) definitions of the same name in more than
- * one translation unit
- */
+bool   Fflag;
+bool   Hflag;
+bool   hflag;
 bool   sflag;
-
 bool   tflag;
-
-/*
- * If a complaint stems from a included file, print the name of the included
- * file instead of the name specified at the command line followed by '?'
- */
-bool   Hflag;
-
-bool   hflag;
-
-/* Print full path names, not only the last component */
-bool   Fflag;
+bool   uflag;
+bool   xflag;
+const char *libname;
 
 /*
  * List of libraries (from -l flag). These libraries are read after all
diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/msg.c
--- a/usr.bin/xlint/lint2/msg.c Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/msg.c Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.c,v 1.20 2023/06/09 13:03:49 rillig Exp $  */
+/*     $NetBSD: msg.c,v 1.21 2023/07/10 12:40:22 rillig Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: msg.c,v 1.20 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: msg.c,v 1.21 2023/07/10 12:40:22 rillig Exp $");
 #endif
 
 #include <stdarg.h>
@@ -102,7 +102,7 @@ lbasename(const char *path)
  * Create a string which describes a position in a source file.
  */
 const char *
-mkpos(pos_t *posp)
+mkpos(const pos_t *posp)
 {
        size_t len;
        const char *fn;
@@ -125,12 +125,10 @@ mkpos(pos_t *posp)
 
        if (len > blen)
                buf = xrealloc(buf, blen = len);
-       if (line != 0) {
-               (void)sprintf(buf, "%s%s(%d)",
-                             fn, qm ? "?" : "", line);
-       } else {
+       if (line != 0)
+               (void)sprintf(buf, "%s%s(%d)", fn, qm ? "?" : "", line);
+       else
                (void)sprintf(buf, "%s", fn);
-       }
 
        return buf;
 }
diff -r 9f022469d1c5 -r b60acb459f67 usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Mon Jul 10 11:46:14 2023 +0000
+++ b/usr.bin/xlint/lint2/read.c        Mon Jul 10 12:40:22 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.84 2023/07/10 09:51:30 rillig Exp $ */
+/* $NetBSD: read.c,v 1.85 2023/07/10 12:40:22 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: read.c,v 1.84 2023/07/10 09:51:30 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.85 2023/07/10 12:40:22 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -246,7 +246,7 @@ readfile(const char *name)
                readfile_line = NULL;
        }
 
-       _destroyhash(renametab);
+       hash_free(renametab);
 
        if (ferror(inp) != 0)
                err(1, "read error on %s", name);
@@ -374,11 +374,11 @@ again:
        name = inpname(cp, &cp);
 



Home | Main Index | Thread Index | Old Index