Module Name: src Committed By: rillig Date: Mon Jan 18 19:24:09 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c func.c lint1.h Log Message: lint: clean up member names of control_structure and comments To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.129 -r1.130 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/lint1.h 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/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.156 src/usr.bin/xlint/lint1/cgram.y:1.157 --- src/usr.bin/xlint/lint1/cgram.y:1.156 Mon Jan 18 18:53:28 2021 +++ src/usr.bin/xlint/lint1/cgram.y Mon Jan 18 19:24:09 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.156 2021/01/18 18:53:28 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.157 2021/01/18 19:24:09 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: cgram.y,v 1.156 2021/01/18 18:53:28 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.157 2021/01/18 19:24:09 rillig Exp $"); #endif #include <limits.h> @@ -2085,7 +2085,8 @@ q_gt(int64_t a, int64_t b) /* * Gets a node for a constant and returns the value of this constant * as integer. - * Is the node not constant or too large for int or of type float, + * + * If the node is not constant or too large for int or of type float, * a warning will be printed. * * toicon() should be used only inside declarations. If it is used in Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.129 src/usr.bin/xlint/lint1/decl.c:1.130 --- src/usr.bin/xlint/lint1/decl.c:1.129 Mon Jan 18 19:21:52 2021 +++ src/usr.bin/xlint/lint1/decl.c Mon Jan 18 19:24:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.129 2021/01/18 19:21:52 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.130 2021/01/18 19:24:09 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.129 2021/01/18 19:21:52 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.130 2021/01/18 19:24:09 rillig Exp $"); #endif #include <sys/param.h> @@ -1287,7 +1287,7 @@ merge_pointers_and_qualifiers(pqinf_t *p * The following 3 functions extend the type of a declarator with * pointer, function and array types. * - * The current type is the Type built by deftyp() (dcs->d_type) and + * The current type is the type built by deftyp() (dcs->d_type) and * pointer, function and array types already added for this * declarator. The new type extension is inserted between both. */ @@ -1464,8 +1464,8 @@ old_style_function(sym_t *decl, sym_t *a } /* - * Lists of Identifiers in functions declarations are allowed only if - * it's also a function definition. If this is not the case, print a + * Lists of identifiers in functions declarations are allowed only if + * it's also a function definition. If this is not the case, print an * error message. */ void @@ -1580,7 +1580,7 @@ declarator_name(sym_t *sym) } /* - * Process a name in the list of formal params in an old style function + * Process a name in the list of formal parameters in an old style function * definition. */ sym_t * @@ -1614,7 +1614,7 @@ old_style_function_name(sym_t *sym) type_t * mktag(sym_t *tag, tspec_t kind, bool decl, bool semi) { - scl_t scl = NOSCL; + scl_t scl; type_t *tp; if (kind == STRUCT) { @@ -2200,10 +2200,10 @@ eqargs(const type_t *tp1, const type_t * /* * mnoarg() (matches functions with no argument type information) - * returns 1 if all parameters of a prototype are compatible with + * returns whether all parameters of a prototype are compatible with * an old style function declaration. * This is the case if the following conditions are met: - * 1. the prototype must have a fixed number of parameters + * 1. the prototype has a fixed number of parameters * 2. no parameter is of type float * 3. no parameter is converted to another type if integer promotion * is applied on it Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.62 src/usr.bin/xlint/lint1/func.c:1.63 --- src/usr.bin/xlint/lint1/func.c:1.62 Sun Jan 17 14:50:11 2021 +++ src/usr.bin/xlint/lint1/func.c Mon Jan 18 19:24:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.62 2021/01/17 14:50:11 rillig Exp $ */ +/* $NetBSD: func.c,v 1.63 2021/01/18 19:24:09 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.62 2021/01/17 14:50:11 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.63 2021/01/18 19:24:09 rillig Exp $"); #endif #include <stdlib.h> @@ -62,7 +62,7 @@ bool reached = true; bool rchflg; /* - * In conjunction with reached, controls printing of "fallthrough on ..." + * In conjunction with 'reached', controls printing of "fallthrough on ..." * warnings. * Reset by each statement and set by FALLTHROUGH, switch (switch1()) * and case (label()). @@ -170,21 +170,20 @@ void popctrl(int env) { cstk_t *ci; - clst_t *cl; + clst_t *cl, *next; lint_assert(cstmt != NULL); lint_assert(cstmt->c_env == env); - cstmt = (ci = cstmt)->c_surrounding; + ci = cstmt; + cstmt = ci->c_surrounding; - while ((cl = ci->c_clst) != NULL) { - ci->c_clst = cl->cl_next; + for (cl = ci->c_clst; cl != NULL; cl = next) { + next = cl->cl_next; free(cl); } - if (ci->c_swtype != NULL) - free(ci->c_swtype); - + free(ci->c_swtype); free(ci); } @@ -304,7 +303,6 @@ funcdef(sym_t *fsym) print_previous_declaration(-1, rdsym); } - /* copy usage information */ copy_usage_info(fsym, rdsym); /* @@ -315,10 +313,8 @@ funcdef(sym_t *fsym) if (fsym->s_osdef && rdsym->s_type->t_proto) fsym->s_def_pos = rdsym->s_def_pos; - /* complete the type */ complete_type(fsym, rdsym); - /* once a function is inline it remains inline */ if (rdsym->s_inline) fsym->s_inline = true; @@ -352,7 +348,7 @@ funcend(void) int n; if (reached) { - cstmt->c_noretval = true; + cstmt->c_had_return_noval = true; if (funcsym->s_type->t_subt->t_tspec != VOID && !funcsym->s_rimpl) { /* func. %s falls off bottom without returning value */ @@ -365,7 +361,8 @@ funcend(void) * declared to be int. Otherwise the wrong return statement * has already printed a warning. */ - if (cstmt->c_noretval && cstmt->c_retval && funcsym->s_rimpl) + if (cstmt->c_had_return_noval && cstmt->c_had_return_value && + funcsym->s_rimpl) /* function %s has return (e); and return; */ warning(216, funcsym->s_name); @@ -388,7 +385,7 @@ funcend(void) if (dcs->d_scl == EXTERN && funcsym->s_inline) { outsym(funcsym, funcsym->s_scl, DECL); } else { - outfdef(funcsym, &dcs->d_fdpos, cstmt->c_retval, + outfdef(funcsym, &dcs->d_fdpos, cstmt->c_had_return_value, funcsym->s_osdef, dcs->d_fargs); } @@ -897,7 +894,6 @@ for2(void) /* * T_GOTO identifier T_SEMI - * T_GOTO error T_SEMI */ void dogoto(sym_t *lab) @@ -974,9 +970,9 @@ doreturn(tnode_t *tn) continue; if (tn != NULL) { - ci->c_retval = true; + ci->c_had_return_value = true; } else { - ci->c_noretval = true; + ci->c_had_return_noval = true; } if (tn != NULL && funcsym->s_type->t_subt->t_tspec == VOID) { Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.58 src/usr.bin/xlint/lint1/lint1.h:1.59 --- src/usr.bin/xlint/lint1/lint1.h:1.58 Sun Jan 17 16:25:30 2021 +++ src/usr.bin/xlint/lint1/lint1.h Mon Jan 18 19:24:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.58 2021/01/17 16:25:30 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.59 2021/01/18 19:24:09 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -387,8 +387,8 @@ typedef struct control_statement { bool c_infinite : 1; /* break condition always false (for (;;), while (1)) */ bool c_rchif : 1; /* end of if-branch reached */ - bool c_noretval : 1; /* had "return;" */ - bool c_retval : 1; /* had "return (e);" */ + bool c_had_return_noval : 1; /* had "return;" */ + bool c_had_return_value : 1; /* had "return (e);" */ type_t *c_swtype; /* type of switch expression */ clst_t *c_clst; /* list of case values */ struct mbl *c_fexprm; /* saved memory for end of loop