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: inline STRUCT_ASSIGN



details:   https://anonhg.NetBSD.org/src/rev/f070ea13f312
branches:  trunk
changeset: 1017534:f070ea13f312
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 30 11:39:55 2020 +0000

description:
lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.

diffstat:

 usr.bin/xlint/common/inittyp.c |   6 ++--
 usr.bin/xlint/common/param.h   |   7 +----
 usr.bin/xlint/lint1/decl.c     |  54 +++++++++++++++++++++---------------------
 usr.bin/xlint/lint1/func.c     |  46 +++++++++++++++++-----------------
 usr.bin/xlint/lint1/lint1.h    |   4 +-
 usr.bin/xlint/lint1/mkops      |   4 +-
 usr.bin/xlint/lint2/read.c     |  14 +++++-----
 7 files changed, 65 insertions(+), 70 deletions(-)

diffs (truncated from 523 to 300 lines):

diff -r f961946a970d -r f070ea13f312 usr.bin/xlint/common/inittyp.c
--- a/usr.bin/xlint/common/inittyp.c    Wed Dec 30 11:14:03 2020 +0000
+++ b/usr.bin/xlint/common/inittyp.c    Wed Dec 30 11:39:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inittyp.c,v 1.12 2018/09/07 15:16:15 christos Exp $    */
+/*     $NetBSD: inittyp.c,v 1.13 2020/12/30 11:39:55 rillig Exp $      */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.12 2018/09/07 15:16:15 christos Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.13 2020/12/30 11:39:55 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -155,7 +155,7 @@
        };
 
        for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
-               STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
+               ttab[ittab[i].it_tspec] = ittab[i].it_ttab;
        if (!pflag) {
                for (i = 0; i < NTSPEC; i++)
                        ttab[i].tt_psz = ttab[i].tt_sz;
diff -r f961946a970d -r f070ea13f312 usr.bin/xlint/common/param.h
--- a/usr.bin/xlint/common/param.h      Wed Dec 30 11:14:03 2020 +0000
+++ b/usr.bin/xlint/common/param.h      Wed Dec 30 11:39:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.6 2020/12/28 21:24:55 rillig Exp $ */
+/*     $NetBSD: param.h,v 1.7 2020/12/30 11:39:55 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -74,8 +74,3 @@
 #else
 typedef        double  ldbl_t;
 #endif
-
-/*
- * Some traditional compilers are not able to assign structures.
- */
-#define STRUCT_ASSIGN(dest, src)       (dest) = (src)
diff -r f961946a970d -r f070ea13f312 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Wed Dec 30 11:14:03 2020 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Wed Dec 30 11:39:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.84 2020/12/30 11:14:03 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.85 2020/12/30 11:39:55 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: decl.c,v 1.84 2020/12/30 11:14:03 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.85 2020/12/30 11:39:55 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -149,7 +149,7 @@
        type_t  *ntp;
 
        ntp = getblk(sizeof (type_t));
-       STRUCT_ASSIGN(*ntp, *tp);
+       *ntp = *tp;
        return ntp;
 }
 
@@ -163,7 +163,7 @@
        type_t  *ntp;
 
        ntp = tgetblk(sizeof (type_t));
-       STRUCT_ASSIGN(*ntp, *tp);
+       *ntp = *tp;
        return ntp;
 }
 
@@ -1951,7 +1951,7 @@
                        if (rdsym->s_osdef && !dsym->s_type->t_proto) {
                                dsym->s_osdef = rdsym->s_osdef;
                                dsym->s_args = rdsym->s_args;
-                               STRUCT_ASSIGN(dsym->s_def_pos, rdsym->s_def_pos);
+                               dsym->s_def_pos = rdsym->s_def_pos;
                        }
 
                        /*
@@ -1961,9 +1961,9 @@
                         * was defined and the new is not.
                         */
                        if (rdsym->s_type->t_proto && !dsym->s_type->t_proto) {
-                               STRUCT_ASSIGN(dsym->s_def_pos, rdsym->s_def_pos);
+                               dsym->s_def_pos = rdsym->s_def_pos;
                        } else if (rdsym->s_def == DEF && dsym->s_def != DEF) {
-                               STRUCT_ASSIGN(dsym->s_def_pos, rdsym->s_def_pos);
+                               dsym->s_def_pos = rdsym->s_def_pos;
                        }
 
                        /*
@@ -2940,7 +2940,7 @@
        if (sym->s_blklev == -1)
                return;
 
-       STRUCT_ASSIGN(cpos, curr_pos);
+       cpos = curr_pos;
 
        if (sym->s_kind == FVFT) {
                if (sym->s_arg) {
@@ -2954,7 +2954,7 @@
                check_tag_usage(sym);
        }
 
-       STRUCT_ASSIGN(curr_pos, cpos);
+       curr_pos = cpos;
 }
 
 static void
@@ -2968,7 +2968,7 @@
                return;
 
        if (!arg->s_used && vflag) {
-               STRUCT_ASSIGN(curr_pos, arg->s_def_pos);
+               curr_pos = arg->s_def_pos;
                /* argument %s unused in function %s */
                warning(231, arg->s_name, funcsym->s_name);
        }
@@ -3001,17 +3001,17 @@
 
        if (sc == EXTERN) {
                if (!sym->s_used && !sym->s_set) {
-                       STRUCT_ASSIGN(curr_pos, sym->s_def_pos);
+                       curr_pos = sym->s_def_pos;
                        /* %s unused in function %s */
                        warning(192, sym->s_name, funcsym->s_name);
                }
        } else {
                if (sym->s_set && !sym->s_used) {
-                       STRUCT_ASSIGN(curr_pos, sym->s_set_pos);
+                       curr_pos = sym->s_set_pos;
                        /* %s set but not used in function %s */
                        warning(191, sym->s_name, funcsym->s_name);
                } else if (!sym->s_used) {
-                       STRUCT_ASSIGN(curr_pos, sym->s_def_pos);
+                       curr_pos = sym->s_def_pos;
                        /* %s unused in function %s */
                        warning(192, sym->s_name, funcsym->s_name);
                }
@@ -3031,11 +3031,11 @@
                if ((xsym = sym->s_ext_sym) != NULL) {
                        if (sym->s_used && !xsym->s_used) {
                                xsym->s_used = 1;
-                               STRUCT_ASSIGN(xsym->s_use_pos, sym->s_use_pos);
+                               xsym->s_use_pos = sym->s_use_pos;
                        }
                        if (sym->s_set && !xsym->s_set) {
                                xsym->s_set = 1;
-                               STRUCT_ASSIGN(xsym->s_set_pos, sym->s_set_pos);
+                               xsym->s_set_pos = sym->s_set_pos;
                        }
                }
        }
@@ -3049,11 +3049,11 @@
                LERROR("check_label_usage()");
 
        if (lab->s_set && !lab->s_used) {
-               STRUCT_ASSIGN(curr_pos, lab->s_set_pos);
+               curr_pos = lab->s_set_pos;
                /* label %s unused in function %s */
                warning(192, lab->s_name, funcsym->s_name);
        } else if (!lab->s_set) {
-               STRUCT_ASSIGN(curr_pos, lab->s_use_pos);
+               curr_pos = lab->s_use_pos;
                /* undefined label %s */
                warning(23, lab->s_name);
        }
@@ -3070,7 +3070,7 @@
        if (!zflag || dcs->d_ctx != EXTERN)
                return;
 
-       STRUCT_ASSIGN(curr_pos, sym->s_def_pos);
+       curr_pos = sym->s_def_pos;
        switch (sym->s_type->t_tspec) {
        case STRUCT:
                /* struct %s never defined */
@@ -3106,7 +3106,7 @@
        if (blklev != 0 || dcs->d_next != NULL)
                norecover();
 
-       STRUCT_ASSIGN(cpos, curr_pos);
+       cpos = curr_pos;
 
        for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) {
                if (sym->s_blklev == -1)
@@ -3121,7 +3121,7 @@
                }
        }
 
-       STRUCT_ASSIGN(curr_pos, cpos);
+       curr_pos = cpos;
 }
 
 static void
@@ -3139,13 +3139,13 @@
        if (sym->s_scl == STATIC) {
                if (sym->s_type->t_tspec == FUNC) {
                        if (sym->s_used && sym->s_def != DEF) {
-                               STRUCT_ASSIGN(curr_pos, sym->s_use_pos);
+                               curr_pos = sym->s_use_pos;
                                /* static func. called but not def.. */
                                error(225, sym->s_name);
                        }
                }
                if (!sym->s_used) {
-                       STRUCT_ASSIGN(curr_pos, sym->s_def_pos);
+                       curr_pos = sym->s_def_pos;
                        if (sym->s_type->t_tspec == FUNC) {
                                if (sym->s_def == DEF) {
                                        if (!sym->s_inline)
@@ -3164,7 +3164,7 @@
                        }
                }
                if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) {
-                       STRUCT_ASSIGN(curr_pos, sym->s_def_pos);
+                       curr_pos = sym->s_def_pos;
                        /* const object %s should have initializer */
                        warning(227, sym->s_name);
                }
@@ -3182,7 +3182,7 @@
                         * after a function declaration
                         */
                        return;
-               STRUCT_ASSIGN(curr_pos, sym->s_def_pos);
+               curr_pos = sym->s_def_pos;
                if (length(sym->s_type, sym->s_name) == 0 &&
                    sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) {
                        /* empty array declaration: %s */
@@ -3206,8 +3206,8 @@
        if (!rflag)
                return;
 
-       STRUCT_ASSIGN(cpos, curr_pos);
-       STRUCT_ASSIGN(curr_pos, psym->s_def_pos);
+       cpos = curr_pos;
+       curr_pos = psym->s_def_pos;
        if (msg != -1) {
                message(msg, psym->s_name);
        } else if (psym->s_def == DEF || psym->s_def == TDEF) {
@@ -3217,5 +3217,5 @@
                /* previous declaration of %s */
                message(260, psym->s_name);
        }
-       STRUCT_ASSIGN(curr_pos, cpos);
+       curr_pos = cpos;
 }
diff -r f961946a970d -r f070ea13f312 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Wed Dec 30 11:14:03 2020 +0000
+++ b/usr.bin/xlint/lint1/func.c        Wed Dec 30 11:39:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.35 2020/12/30 11:14:03 rillig Exp $ */
+/*     $NetBSD: func.c,v 1.36 2020/12/30 11:39:55 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.35 2020/12/30 11:14:03 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.36 2020/12/30 11:39:55 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -285,7 +285,7 @@
         * if this is an old style definition and we had already a
         * prototype.
         */
-       STRUCT_ASSIGN(dcs->d_fdpos, fsym->s_def_pos);
+       dcs->d_fdpos = fsym->s_def_pos;
 
        if ((rdsym = dcs->d_rdcsym) != NULL) {
 
@@ -311,7 +311,7 @@
                         * declaration of the prototype.
                         */
                        if (fsym->s_osdef && rdsym->s_type->t_proto)
-                               STRUCT_ASSIGN(fsym->s_def_pos, rdsym->s_def_pos);
+                               fsym->s_def_pos = rdsym->s_def_pos;
 
                        /* complete the type */
                        complete_type(fsym, rdsym);
@@ -494,7 +494,7 @@
                                 * case values
                                 */
                                cl = xcalloc(1, sizeof (clst_t));
-                               STRUCT_ASSIGN(cl->cl_val, nv);
+                               cl->cl_val = nv;
                                cl->cl_next = ci->c_clst;



Home | Main Index | Thread Index | Old Index