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: un-abbreviate members of sym_t



details:   https://anonhg.NetBSD.org/src/rev/081e131ac6f5
branches:  trunk
changeset: 985527:081e131ac6f5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 29 10:13:02 2021 +0000

description:
lint: un-abbreviate members of sym_t

No functional change.

diffstat:

 usr.bin/xlint/lint2/chk.c   |  28 +++++++++++++++-----------
 usr.bin/xlint/lint2/emit2.c |  30 ++++++++++++++--------------
 usr.bin/xlint/lint2/lint2.h |  48 +++++++++++++++++++++-----------------------
 usr.bin/xlint/lint2/read.c  |  43 ++++++++++++++++++++-------------------
 4 files changed, 76 insertions(+), 73 deletions(-)

diffs (truncated from 320 to 300 lines):

diff -r c45f7bf357d9 -r 081e131ac6f5 usr.bin/xlint/lint2/chk.c
--- a/usr.bin/xlint/lint2/chk.c Sun Aug 29 09:54:18 2021 +0000
+++ b/usr.bin/xlint/lint2/chk.c Sun Aug 29 10:13:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.44 2021/08/22 04:43:44 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.45 2021/08/29 10:13: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: chk.c,v 1.44 2021/08/22 04:43:44 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.45 2021/08/29 10:13:02 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -382,7 +382,8 @@
                ap2 = tp2->t_args;
                n = 0;
                while (*ap1 != NULL && *ap2 != NULL) {
-                       if (def != NULL && def->s_va && n >= def->s_nva)
+                       if (def != NULL && def->s_check_only_first_args &&
+                           n >= def->s_check_num_args)
                                break;
                        n++;
                        chkau(hte, n, def, decl, pos1p, call1, call,
@@ -392,7 +393,8 @@
                }
                if (*ap1 == *ap2) {
                        /* equal # of arguments */
-               } else if (def != NULL && def->s_va && n >= def->s_nva) {
+               } else if (def != NULL && def->s_check_only_first_args &&
+                          n >= def->s_check_num_args) {
                        /*
                         * function definition with VARARGS; The # of
                         * arguments of the call must be at least as large
@@ -413,16 +415,18 @@
                }
 
                /* perform SCANFLIKE/PRINTFLIKE tests */
-               if (def == NULL || (!def->s_prfl && !def->s_scfl))
+               if (def == NULL || (!def->s_printflike && !def->s_scanflike))
                        continue;
-               as = def->s_prfl ? def->s_nprfl : def->s_nscfl;
+               as = def->s_printflike
+                   ? def->s_printflike_arg
+                   : def->s_scanflike_arg;
                for (ai = call->f_args; ai != NULL; ai = ai->a_next) {
                        if (ai->a_num == as)
                                break;
                }
                if (ai == NULL || !ai->a_fmt)
                        continue;
-               if (def->s_prfl) {
+               if (def->s_printflike) {
                        printflike(hte, call, n, ai->a_fstrg, ap2);
                } else {
                        scanflike(hte, call, n, ai->a_fstrg, ap2);
@@ -463,7 +467,7 @@
         */
 
        /* arg1 must be promoted if it stems from an old style definition */
-       promote = def != NULL && def->s_osdef;
+       promote = def != NULL && def->s_old_style_function;
 
        /*
         * If we compare with a definition or declaration, we must perform
@@ -1078,7 +1082,7 @@
        if (hte->h_calls == NULL)
                return;
 
-       if (def->s_rval) {
+       if (def->s_function_has_return_value) {
                /*
                 * XXX as soon as we are able to disable single warnings
                 * the following dependencies from hflag should be removed.
@@ -1130,7 +1134,7 @@
 
        osdef = false;
        if (def != NULL) {
-               osdef = def->s_osdef;
+               osdef = def->s_old_style_function;
                sym1 = def;
        } else if (decl != NULL && TP(decl->s_type)->t_proto) {
                sym1 = decl;
@@ -1173,8 +1177,8 @@
                        tp2 = TP(sym->s_type);
                        if (tp1->t_vararg == tp2->t_vararg)
                                continue;
-                       if (tp2->t_vararg &&
-                           sym1->s_va && sym1->s_nva == n && !sflag) {
+                       if (tp2->t_vararg && sym1->s_check_only_first_args &&
+                           sym1->s_check_num_args == n && !sflag) {
                                continue;
                        }
                }
diff -r c45f7bf357d9 -r 081e131ac6f5 usr.bin/xlint/lint2/emit2.c
--- a/usr.bin/xlint/lint2/emit2.c       Sun Aug 29 09:54:18 2021 +0000
+++ b/usr.bin/xlint/lint2/emit2.c       Sun Aug 29 10:13:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit2.c,v 1.22 2021/08/28 17:18:42 rillig Exp $ */
+/* $NetBSD: emit2.c,v 1.23 2021/08/29 10:13:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit2.c,v 1.22 2021/08/28 17:18:42 rillig Exp $");
+__RCSID("$NetBSD: emit2.c,v 1.23 2021/08/29 10:13:02 rillig Exp $");
 #endif
 
 #include "lint2.h"
@@ -160,25 +160,25 @@
        outint(0);
 
        /* flags */
-       if (sym->s_va) {
-               outchar('v');           /* varargs */
-               outint(sym->s_nva);
+       if (sym->s_check_only_first_args) {
+               outchar('v');
+               outint(sym->s_check_num_args);
        }
-       if (sym->s_scfl) {
-               outchar('S');           /* scanflike */
-               outint(sym->s_nscfl);
+       if (sym->s_scanflike) {
+               outchar('S');
+               outint(sym->s_scanflike_arg);
        }
-       if (sym->s_prfl) {
-               outchar('P');           /* printflike */
-               outint(sym->s_nprfl);
+       if (sym->s_printflike) {
+               outchar('P');
+               outint(sym->s_printflike_arg);
        }
        /* definition or tentative definition */
        outchar(sym->s_def == DEF ? 'd' : 't');
        if (TP(sym->s_type)->t_tspec == FUNC) {
-               if (sym->s_rval)
-                       outchar('r');   /* fkt. has return value */
-               if (sym->s_osdef)
-                       outchar('o');   /* old style definition */
+               if (sym->s_function_has_return_value)
+                       outchar('r');
+               if (sym->s_old_style_function)
+                       outchar('o');
        }
        outchar('u');                   /* used (no warning if not used) */
 
diff -r c45f7bf357d9 -r 081e131ac6f5 usr.bin/xlint/lint2/lint2.h
--- a/usr.bin/xlint/lint2/lint2.h       Sun Aug 29 09:54:18 2021 +0000
+++ b/usr.bin/xlint/lint2/lint2.h       Sun Aug 29 10:13:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint2.h,v 1.18 2021/08/29 09:48:02 rillig Exp $ */
+/* $NetBSD: lint2.h,v 1.19 2021/08/29 10:13:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -103,14 +103,7 @@
        unsigned short p_iline; /* line number in p_iline */
 } pos_t;
 
-/*
- * Used for definitions and declarations
- *
- * To save memory, variable sized structures are used. If
- * all s_va, s_prfl and s_scfl are not set, the memory allocated
- * for a symbol is only large enough to keep the first member of
- * struct sym, s_s.
- */
+/* Used for definitions and declarations. */
 typedef        struct sym {
        struct {
                pos_t   s_pos;          /* pos of def./decl. */
@@ -119,30 +112,35 @@
 #else
                def_t   s_def;
 #endif
-               bool    s_rval : 1;     /* function has return value */
-               bool    s_inline : 1;   /* function is inline */
-               bool    s_osdef : 1;    /* old style function definition */
-               bool    s_static : 1;   /* symbol is static */
-               bool    s_va : 1;       /* check only first s_nva arguments */
-               bool    s_prfl : 1;     /* printflike */
-               bool    s_scfl : 1;     /* scanflike */
-               unsigned short s_type;  /* type */
+               bool    s_function_has_return_value : 1;
+               bool    s_inline : 1;
+               bool    s_old_style_function : 1;
+               bool    s_static : 1;
+               bool    s_check_only_first_args : 1;
+               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;
-       short   s_nva;
-       short   s_nprfl;
-       short   s_nscfl;
+       /*
+        * To save memory, the remaining members are only allocated if one of
+        * s_check_only_first_args, s_printflike and s_scanflike is set.
+        */
+       short   s_check_num_args;       /* if s_check_only_first_args */
+       short   s_printflike_arg;       /* if s_printflike */
+       short   s_scanflike_arg;        /* if s_scanflike */
 } sym_t;
 
 #define s_pos          s_s.s_pos
-#define s_rval         s_s.s_rval
-#define s_osdef                s_s.s_osdef
+#define s_function_has_return_value s_s.s_function_has_return_value
+#define s_old_style_function s_s.s_old_style_function
 #define s_inline       s_s.s_inline
 #define s_static       s_s.s_static
 #define s_def          s_s.s_def
-#define s_va           s_s.s_va
-#define s_prfl         s_s.s_prfl
-#define s_scfl         s_s.s_scfl
+#define s_check_only_first_args        s_s.s_check_only_first_args
+#define s_printflike   s_s.s_printflike
+#define s_scanflike    s_s.s_scanflike
 #define s_type         s_s.s_type
 #define s_next         s_s.s_next
 
diff -r c45f7bf357d9 -r 081e131ac6f5 usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Sun Aug 29 09:54:18 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Sun Aug 29 10:13:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.56 2021/08/28 12:21:53 rillig Exp $ */
+/* $NetBSD: read.c,v 1.57 2021/08/29 10:13: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: read.c,v 1.56 2021/08/28 12:21:53 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.57 2021/08/29 10:13:02 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -407,14 +407,14 @@
                        sym.s_inline = true;
                        break;
                case 'o':
-                       if (sym.s_osdef)
+                       if (sym.s_old_style_function)
                                inperr("osdef");
-                       sym.s_osdef = true;
+                       sym.s_old_style_function = true;
                        break;
                case 'r':
-                       if (sym.s_rval)
-                               inperr("rval");
-                       sym.s_rval = true;
+                       if (sym.s_function_has_return_value)
+                               inperr("r");
+                       sym.s_function_has_return_value = true;
                        break;
                case 's':
                        if (sym.s_static)
@@ -432,22 +432,22 @@
                        used = true;
                        break;
                case 'v':
-                       if (sym.s_va)
-                               inperr("va");
-                       sym.s_va = true;
-                       sym.s_nva = parse_short(&cp);
+                       if (sym.s_check_only_first_args)
+                               inperr("v");
+                       sym.s_check_only_first_args = true;
+                       sym.s_check_num_args = parse_short(&cp);
                        break;
                case 'P':
-                       if (sym.s_prfl)
-                               inperr("prfl");
-                       sym.s_prfl = true;
-                       sym.s_nprfl = parse_short(&cp);
+                       if (sym.s_printflike)
+                               inperr("P");
+                       sym.s_printflike = true;
+                       sym.s_printflike_arg = parse_short(&cp);
                        break;
                case 'S':
-                       if (sym.s_scfl)
-                               inperr("scfl");
-                       sym.s_scfl = true;
-                       sym.s_nscfl = parse_short(&cp);
+                       if (sym.s_scanflike)
+                               inperr("S");



Home | Main Index | Thread Index | Old Index