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 code (mostly comments)



details:   https://anonhg.NetBSD.org/src/rev/ed855769c516
branches:  trunk
changeset: 950166:ed855769c516
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jan 18 20:02:34 2021 +0000

description:
lint: clean up code (mostly comments)

diffstat:

 tests/usr.bin/xlint/lint1/t_integration.sh |   5 +-
 usr.bin/xlint/lint1/func.c                 |   6 +-
 usr.bin/xlint/lint1/mem1.c                 |   6 +-
 usr.bin/xlint/lint1/oper.c                 |   5 +-
 usr.bin/xlint/lint1/scan.l                 |  34 +++++++-------
 usr.bin/xlint/lint1/tree.c                 |  72 +++++++++++++----------------
 usr.bin/xlint/lint2/chk.c                  |  10 ++--
 7 files changed, 66 insertions(+), 72 deletions(-)

diffs (truncated from 482 to 300 lines):

diff -r a96a82f31383 -r ed855769c516 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Mon Jan 18 19:24:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Mon Jan 18 20:02:34 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.27 2021/01/17 23:00:41 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.28 2021/01/18 20:02:34 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -177,7 +177,8 @@
                                "'long int'; PR bin/39639"
 
 test_case all_messages
-all_messages_body() {
+all_messages_body()
+{
        local srcdir ok msg base flags
 
        srcdir="$(atf_get_srcdir)"
diff -r a96a82f31383 -r ed855769c516 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Mon Jan 18 19:24:09 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Mon Jan 18 20:02:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.63 2021/01/18 19:24:09 rillig Exp $ */
+/*     $NetBSD: func.c,v 1.64 2021/01/18 20:02:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.63 2021/01/18 19:24:09 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.64 2021/01/18 20:02:34 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -462,7 +462,7 @@
         * to the type of the switch expression
         */
        v = constant(tn, true);
-       (void) memset(&nv, 0, sizeof nv);
+       (void)memset(&nv, 0, sizeof nv);
        convert_constant(CASE, 0, ci->c_swtype, &nv, v);
        free(v);
 
diff -r a96a82f31383 -r ed855769c516 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c        Mon Jan 18 19:24:09 2021 +0000
+++ b/usr.bin/xlint/lint1/mem1.c        Mon Jan 18 20:02:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem1.c,v 1.23 2021/01/16 02:40:02 rillig Exp $ */
+/*     $NetBSD: mem1.c,v 1.24 2021/01/18 20:02:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.23 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.24 2021/01/18 20:02:34 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -140,7 +140,7 @@
 
        if ((fn = srchfn(s, len)) == NULL) {
                fn = xmalloc(sizeof (fn_t));
-               /* Do not used strdup() because string is not NUL-terminated.*/
+               /* Do not use strdup() because string is not NUL-terminated.*/
                fn->fn_name = xmalloc(len + 1);
                (void)memcpy(fn->fn_name, s, len);
                fn->fn_name[len] = '\0';
diff -r a96a82f31383 -r ed855769c516 usr.bin/xlint/lint1/oper.c
--- a/usr.bin/xlint/lint1/oper.c        Mon Jan 18 19:24:09 2021 +0000
+++ b/usr.bin/xlint/lint1/oper.c        Mon Jan 18 20:02:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: oper.c,v 1.4 2021/01/16 02:40:02 rillig Exp $  */
+/*     $NetBSD: oper.c,v 1.5 2021/01/18 20:02:34 rillig Exp $  */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -51,7 +51,8 @@
 #include "ops.def"
 
 const char *
-getopname(op_t op) {
+getopname(op_t op)
+{
        return imods[op].m.m_name;
 }
 
diff -r a96a82f31383 -r ed855769c516 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Mon Jan 18 19:24:09 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Mon Jan 18 20:02:34 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.128 2021/01/18 17:54:50 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.129 2021/01/18 20:02:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.128 2021/01/18 17:54:50 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.129 2021/01/18 20:02:34 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -108,11 +108,11 @@
 0{OD}*[lLuU]*                  return icon(8);
 {NZD}{D}*[lLuU]*               return icon(10);
 0[xX]{HD}+[lLuU]*              return icon(16);
-{D}+\.{D}*{EX}?{TL}    |
-{D}+{EX}{TL}           |
-0[xX]{HD}+\.{HD}*{HX}{TL} |
-0[xX]{HD}+{HX}{TL}     |
-\.{D}+{EX}?{TL}                return fcon();
+{D}+\.{D}*{EX}?{TL}            |
+{D}+{EX}{TL}                   |
+0[xX]{HD}+\.{HD}*{HX}{TL}      |
+0[xX]{HD}+{HX}{TL}             |
+\.{D}+{EX}?{TL}                        return fcon();
 "="                            return operator(T_ASSIGN, NOOP);
 "*="                           return operator(T_OPASSIGN, MULASS);
 "/="                           return operator(T_OPASSIGN, DIVASS);
@@ -328,7 +328,7 @@
 /* free list for sbuf structures */
 static sbuf_t   *sbfrlst;
 
-/* Typ of next expected symbol */
+/* type of next expected symbol */
 symt_t symtyp;
 
 
@@ -598,7 +598,7 @@
 
        /* read suffixes */
        l_suffix = u_suffix = 0;
-       for ( ; ; ) {
+       for (;;) {
                if ((c = cp[len - 1]) == 'l' || c == 'L') {
                        l_suffix++;
                } else if (c == 'u' || c == 'U') {
@@ -1225,14 +1225,14 @@
  *     PROTOLIB
  *     SCANFLIKEn
  *     VARARGSn
- * If one of this comments is recognized, the arguments, if any, are
+ * If one of these comments is recognized, the argument, if any, is
  * parsed and a function which handles this comment is called.
  */
 static void
 comment(void)
 {
        int     c, lc;
-       static struct {
+       static const struct {
                const   char *keywd;
                int     arg;
                void    (*func)(int);
@@ -1262,7 +1262,7 @@
 
        eoc = false;
 
-       /* Skip white spaces after the start of the comment */
+       /* Skip whitespace after the start of the comment */
        while ((c = inpc()) != EOF && isspace(c))
                continue;
 
@@ -1282,7 +1282,7 @@
        if (i == sizeof (keywtab) / sizeof (keywtab[0]))
                goto skip_rest;
 
-       /* skip white spaces after the keyword */
+       /* skip whitespace after the keyword */
        while (c != EOF && isspace(c))
                c = inpc();
 
@@ -1297,7 +1297,7 @@
        arg[l] = '\0';
        a = l != 0 ? atoi(arg) : -1;
 
-       /* skip white spaces after the argument */
+       /* skip whitespace after the argument */
        while (c != EOF && isspace(c))
                c = inpc();
 
@@ -1462,9 +1462,9 @@
  *
  * getsym() is called as soon as it is probably ok to put the symbol to
  * the symbol table. This does not mean that it is not possible that
- * symbols are put to the symbol table which are than not completely
+ * symbols are put to the symbol table which are not completely
  * declared due to syntax errors. To avoid too many problems in this
- * case symbols get type int in getsym().
+ * case, symbols get type int in getsym().
  *
  * XXX calls to getsym() should be delayed until decl1*() is called
  */
@@ -1498,7 +1498,7 @@
 
        /* create a new symbol table entry */
 
-       /* labels must always be allocated at level 1 (outhermost block) */
+       /* labels must always be allocated at level 1 (outermost block) */
        if (symtyp == FLABEL) {
                sym = getlblk(1, sizeof (sym_t));
                s = getlblk(1, sb->sb_len + 1);
diff -r a96a82f31383 -r ed855769c516 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Jan 18 19:24:09 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Jan 18 20:02:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.181 2021/01/17 23:04:09 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.182 2021/01/18 20:02:34 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.181 2021/01/17 23:04:09 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.182 2021/01/18 20:02:34 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -342,8 +342,8 @@
        tspec_t t;
 
        /*
-        * Remove the member if it was unknown until now (Which means
-        * that no defined struct or union has a member with the same name).
+        * Remove the member if it was unknown until now, which means
+        * that no defined struct or union has a member with the same name.
         */
        if (msym->s_scl == NOSCL) {
                /* undefined struct/union member: %s */
@@ -371,8 +371,7 @@
        }
 
        /*
-        * If this struct/union has a member with the name of msym, return
-        * return this it.
+        * If this struct/union has a member with the name of msym, return it.
         */
        if (str != NULL) {
                for (sym = msym; sym != NULL; sym = sym->s_link) {
@@ -912,11 +911,12 @@
 }
 
 static void
-typeok_shl(const mod_t *mp, tspec_t lt, tspec_t rt) {
+typeok_shl(const mod_t *mp, tspec_t lt, tspec_t rt)
+{
        /*
-        * ANSI C does not perform balancing for shift operations,
+        * C90 does not perform balancing for shift operations,
         * but traditional C does. If the width of the right operand
-        * is greater than the width of the left operand, than in
+        * is greater than the width of the left operand, then in
         * traditional C the left operand would be extended to the
         * width of the right operand. For SHL this may result in
         * different results.
@@ -1648,10 +1648,7 @@
        return false;
 }
 
-/*
- * Prints a warning if an operator, which should be senseless for an
- * enum type, is applied to an enum type.
- */
+/* Prints a warning if a strange operator is used on an enum type. */
 static void
 check_bad_enum_operation(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
@@ -1720,10 +1717,7 @@
        }
 }
 
-/*
- * Prints a warning if an operator has both enum and other integer
- * types.
- */
+/* Prints a warning if the operands mix between enum and integer. */
 static void
 check_enum_int_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
 {
@@ -1734,9 +1728,8 @@
        switch (op) {
        case INIT:
                /*
-                * Initializations with 0 should be allowed. Otherwise,
-                * we should complain about all uninitialized enums,
-                * consequently.
+                * Initialization with 0 is allowed. Otherwise, all implicit
+                * initializations would need to be warned upon as well.
                 */



Home | Main Index | Thread Index | Old Index