Module Name: src Committed By: rillig Date: Wed Dec 30 11:39:55 UTC 2020
Modified Files: src/usr.bin/xlint/common: inittyp.c param.h src/usr.bin/xlint/lint1: decl.c func.c lint1.h mkops src/usr.bin/xlint/lint2: read.c Log Message: lint: inline STRUCT_ASSIGN This had only been necessary for some pre-C90 compilers. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/common/param.h cvs rdiff -u -r1.84 -r1.85 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/mkops cvs rdiff -u -r1.33 -r1.34 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/common/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.12 src/usr.bin/xlint/common/inittyp.c:1.13 --- src/usr.bin/xlint/common/inittyp.c:1.12 Fri Sep 7 15:16:15 2018 +++ src/usr.bin/xlint/common/inittyp.c Wed Dec 30 11:39:55 2020 @@ -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 @@ inittyp(void) }; 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; Index: src/usr.bin/xlint/common/param.h diff -u src/usr.bin/xlint/common/param.h:1.6 src/usr.bin/xlint/common/param.h:1.7 --- src/usr.bin/xlint/common/param.h:1.6 Mon Dec 28 21:24:55 2020 +++ src/usr.bin/xlint/common/param.h Wed Dec 30 11:39:55 2020 @@ -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 @@ typedef long double ldbl_t; #else typedef double ldbl_t; #endif - -/* - * Some traditional compilers are not able to assign structures. - */ -#define STRUCT_ASSIGN(dest, src) (dest) = (src) Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.84 src/usr.bin/xlint/lint1/decl.c:1.85 --- src/usr.bin/xlint/lint1/decl.c:1.84 Wed Dec 30 11:14:03 2020 +++ src/usr.bin/xlint/lint1/decl.c Wed Dec 30 11:39:55 2020 @@ -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 @@ duptyp(const type_t *tp) type_t *ntp; ntp = getblk(sizeof (type_t)); - STRUCT_ASSIGN(*ntp, *tp); + *ntp = *tp; return ntp; } @@ -163,7 +163,7 @@ tduptyp(const type_t *tp) type_t *ntp; ntp = tgetblk(sizeof (type_t)); - STRUCT_ASSIGN(*ntp, *tp); + *ntp = *tp; return ntp; } @@ -1951,7 +1951,7 @@ decl1ext(sym_t *dsym, int initflg) 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 @@ decl1ext(sym_t *dsym, int initflg) * 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 @@ check_usage_sym(int novar, sym_t *sym) 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_usage_sym(int novar, sym_t *sym) check_tag_usage(sym); } - STRUCT_ASSIGN(curr_pos, cpos); + curr_pos = cpos; } static void @@ -2968,7 +2968,7 @@ check_argument_usage(int novar, sym_t *a 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 @@ check_variable_usage(int novar, sym_t *s 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 @@ check_variable_usage(int novar, sym_t *s 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 @@ check_label_usage(sym_t *lab) 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 @@ check_tag_usage(sym_t *sym) 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 @@ check_global_symbols(void) 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 @@ check_global_symbols(void) } } - STRUCT_ASSIGN(curr_pos, cpos); + curr_pos = cpos; } static void @@ -3139,13 +3139,13 @@ check_global_variable(sym_t *sym) 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 @@ check_global_variable(sym_t *sym) } } 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 @@ check_global_variable_size(sym_t *sym) * 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 @@ print_previous_declaration(int msg, sym_ 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 @@ print_previous_declaration(int msg, sym_ /* previous declaration of %s */ message(260, psym->s_name); } - STRUCT_ASSIGN(curr_pos, cpos); + curr_pos = cpos; } Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.35 src/usr.bin/xlint/lint1/func.c:1.36 --- src/usr.bin/xlint/lint1/func.c:1.35 Wed Dec 30 11:14:03 2020 +++ src/usr.bin/xlint/lint1/func.c Wed Dec 30 11:39:55 2020 @@ -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 @@ funcdef(sym_t *fsym) * 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 @@ funcdef(sym_t *fsym) * 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 @@ label(int typ, sym_t *sym, tnode_t *tn) * case values */ cl = xcalloc(1, sizeof (clst_t)); - STRUCT_ASSIGN(cl->cl_val, nv); + cl->cl_val = nv; cl->cl_next = ci->c_clst; ci->c_clst = cl; } @@ -821,8 +821,8 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t */ cstk->c_fexprm = tsave(); cstk->c_f3expr = tn3; - STRUCT_ASSIGN(cstk->c_fpos, curr_pos); - STRUCT_ASSIGN(cstk->c_cfpos, csrc_pos); + cstk->c_fpos = curr_pos; + cstk->c_cfpos = csrc_pos; if (tn1 != NULL) expr(tn1, 0, 0, 1); @@ -867,14 +867,14 @@ for2(void) if (cstk->c_cont) reached = 1; - STRUCT_ASSIGN(cpos, curr_pos); - STRUCT_ASSIGN(cspos, csrc_pos); + cpos = curr_pos; + cspos = csrc_pos; /* Restore the tree memory for the reinitialisation expression */ trestor(cstk->c_fexprm); tn3 = cstk->c_f3expr; - STRUCT_ASSIGN(curr_pos, cstk->c_fpos); - STRUCT_ASSIGN(csrc_pos, cstk->c_cfpos); + curr_pos = cstk->c_fpos; + csrc_pos = cstk->c_cfpos; /* simply "statement not reached" would be confusing */ if (!reached && !rchflg) { @@ -889,8 +889,8 @@ for2(void) tfreeblk(); } - STRUCT_ASSIGN(curr_pos, cpos); - STRUCT_ASSIGN(csrc_pos, cspos); + curr_pos = cpos; + csrc_pos = cspos; /* An endless loop without break will never terminate */ reached = cstk->c_break || !cstk->c_infinite; @@ -1041,11 +1041,11 @@ global_clean_up_decl(int silent) { pos_t cpos; - STRUCT_ASSIGN(cpos, curr_pos); + cpos = curr_pos; if (nargusg != -1) { if (!silent) { - STRUCT_ASSIGN(curr_pos, argsused_pos); + curr_pos = argsused_pos; /* must precede function definition: %s */ warning(282, "ARGSUSED"); } @@ -1053,7 +1053,7 @@ global_clean_up_decl(int silent) } if (nvararg != -1) { if (!silent) { - STRUCT_ASSIGN(curr_pos, vapos); + curr_pos = vapos; /* must precede function definition: %s */ warning(282, "VARARGS"); } @@ -1061,7 +1061,7 @@ global_clean_up_decl(int silent) } if (prflstrg != -1) { if (!silent) { - STRUCT_ASSIGN(curr_pos, printflike_pos); + curr_pos = printflike_pos; /* must precede function definition: %s */ warning(282, "PRINTFLIKE"); } @@ -1069,14 +1069,14 @@ global_clean_up_decl(int silent) } if (scflstrg != -1) { if (!silent) { - STRUCT_ASSIGN(curr_pos, scanflike_pos); + curr_pos = scanflike_pos; /* must precede function definition: %s */ warning(282, "SCANFLIKE"); } scflstrg = -1; } - STRUCT_ASSIGN(curr_pos, cpos); + curr_pos = cpos; dcs->d_asm = 0; } @@ -1104,7 +1104,7 @@ argsused(int n) warning(281, "ARGSUSED"); } nargusg = n; - STRUCT_ASSIGN(argsused_pos, curr_pos); + argsused_pos = curr_pos; } /* @@ -1130,7 +1130,7 @@ varargs(int n) warning(281, "VARARGS"); } nvararg = n; - STRUCT_ASSIGN(vapos, curr_pos); + vapos = curr_pos; } /* @@ -1156,7 +1156,7 @@ printflike(int n) warning(281, "PRINTFLIKE"); } prflstrg = n; - STRUCT_ASSIGN(printflike_pos, curr_pos); + printflike_pos = curr_pos; } /* @@ -1182,7 +1182,7 @@ scanflike(int n) warning(281, "SCANFLIKE"); } scflstrg = n; - STRUCT_ASSIGN(scanflike_pos, curr_pos); + scanflike_pos = curr_pos; } /* Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.44 src/usr.bin/xlint/lint1/lint1.h:1.45 --- src/usr.bin/xlint/lint1/lint1.h:1.44 Wed Dec 30 11:14:03 2020 +++ src/usr.bin/xlint/lint1/lint1.h Wed Dec 30 11:39:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.44 2020/12/30 11:14:03 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.45 2020/12/30 11:39:55 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -66,7 +66,7 @@ typedef struct { /* Copies curr_pos, keeping things unique. */ #define UNIQUE_CURR_POS(pos) \ do { \ - STRUCT_ASSIGN((pos), curr_pos); \ + (pos) = curr_pos; \ curr_pos.p_uniq++; \ if (curr_pos.p_file == csrc_pos.p_file) \ csrc_pos.p_uniq++; \ Index: src/usr.bin/xlint/lint1/mkops diff -u src/usr.bin/xlint/lint1/mkops:1.9 src/usr.bin/xlint/lint1/mkops:1.10 --- src/usr.bin/xlint/lint1/mkops:1.9 Mon Dec 28 19:47:42 2020 +++ src/usr.bin/xlint/lint1/mkops Wed Dec 30 11:39:55 2020 @@ -1,5 +1,5 @@ #!/bin/sh - -# $NetBSD: mkops,v 1.9 2020/12/28 19:47:42 rillig Exp $ +# $NetBSD: mkops,v 1.10 2020/12/30 11:39:55 rillig Exp $ # # Copyright (c) 2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -124,7 +124,7 @@ END { printf("\n"); printf("\tfor (i = 0; i < __arraycount(imods); i++)\n"); printf("\t\tif (imods[i].ok)\n"); - printf("\t\t\tSTRUCT_ASSIGN(modtab[i], imods[i].m);\n"); + printf("\t\t\tmodtab[i] = imods[i].m;\n"); printf("}\n"); } } Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.33 src/usr.bin/xlint/lint2/read.c:1.34 --- src/usr.bin/xlint/lint2/read.c:1.33 Wed Dec 30 10:46:11 2020 +++ src/usr.bin/xlint/lint2/read.c Wed Dec 30 11:39:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.33 2020/12/30 10:46:11 rillig Exp $ */ +/* $NetBSD: read.c,v 1.34 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: read.c,v 1.33 2020/12/30 10:46:11 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.34 2020/12/30 11:39:55 rillig Exp $"); #endif #include <ctype.h> @@ -283,7 +283,7 @@ funccall(pos_t *posp, const char *cp) const char *name; fcall = xalloc(sizeof (fcall_t)); - STRUCT_ASSIGN(fcall->f_pos, *posp); + fcall->f_pos = *posp; /* read flags */ rused = rdisc = 0; @@ -366,7 +366,7 @@ decldef(pos_t *posp, const char *cp) const char *name, *newname; (void)memset(&sym, 0, sizeof (sym)); - STRUCT_ASSIGN(sym.s_pos, *posp); + sym.s_pos = *posp; sym.s_def = NODECL; used = 0; @@ -501,10 +501,10 @@ decldef(pos_t *posp, const char *cp) /* allocsym reserviert keinen Platz fuer s_nva */ if (sym.s_va || sym.s_prfl || sym.s_scfl) { symp = xalloc(sizeof (sym_t)); - STRUCT_ASSIGN(*symp, sym); + *symp = sym; } else { symp = xalloc(sizeof (symp->s_s)); - STRUCT_ASSIGN(symp->s_s, sym.s_s); + symp->s_s = sym.s_s; } *hte->h_lsym = symp; hte->h_lsym = &symp->s_next; @@ -529,7 +529,7 @@ usedsym(pos_t *posp, const char *cp) const char *name; usym = xalloc(sizeof (usym_t)); - STRUCT_ASSIGN(usym->u_pos, *posp); + usym->u_pos = *posp; /* needed as delimiter between two numbers */ if (*cp++ != 'x')