Module Name: src Committed By: rillig Date: Sun Aug 28 10:43:19 UTC 2022
Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h tree.c src/usr.bin/xlint/lint2: chk.c Log Message: lint: rename functions to be clearer No need anymore to keep external identifiers at the "6 significant initial characters" mandated by C90. To generate a diff of this commit: cvs rdiff -u -r1.422 -r1.423 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.296 -r1.297 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.166 -r1.167 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.477 -r1.478 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.49 -r1.50 src/usr.bin/xlint/lint2/chk.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/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.422 src/usr.bin/xlint/lint1/cgram.y:1.423 --- src/usr.bin/xlint/lint1/cgram.y:1.422 Sun Aug 28 08:41:06 2022 +++ src/usr.bin/xlint/lint1/cgram.y Sun Aug 28 10:43:18 2022 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.422 2022/08/28 08:41:06 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.423 2022/08/28 10:43:18 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: cgram.y,v 1.422 2022/08/28 08:41:06 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.423 2022/08/28 10:43:18 rillig Exp $"); #endif #include <limits.h> @@ -872,15 +872,15 @@ struct_or_union_specifier: /* C99 6.7.2. * yychar is valid because otherwise the parser would not * have been able to decide if it must shift or reduce */ - $$ = mktag($2, $1, false, yychar == T_SEMI); + $$ = make_tag_type($2, $1, false, yychar == T_SEMI); } | struct_or_union identifier_sym { - dcs->d_tagtyp = mktag($2, $1, true, false); + dcs->d_tagtyp = make_tag_type($2, $1, true, false); } braced_struct_declaration_list { $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $4); } | struct_or_union { - dcs->d_tagtyp = mktag(NULL, $1, true, false); + dcs->d_tagtyp = make_tag_type(NULL, $1, true, false); } braced_struct_declaration_list { $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $3); } @@ -924,7 +924,7 @@ struct_declaration_list_with_rbrace: /* struct_declaration_list: /* C99 6.7.2.1 */ struct_declaration | struct_declaration_list struct_declaration { - $$ = lnklst($1, $2); + $$ = concat_lists($1, $2); } ; @@ -980,7 +980,7 @@ notype_struct_declarators: | notype_struct_declarators { symtyp = FMEMBER; } T_COMMA type_struct_declarator { - $$ = lnklst($1, declarator_1_struct_union($4)); + $$ = concat_lists($1, declarator_1_struct_union($4)); } ; @@ -991,46 +991,46 @@ type_struct_declarators: | type_struct_declarators { symtyp = FMEMBER; } T_COMMA type_struct_declarator { - $$ = lnklst($1, declarator_1_struct_union($4)); + $$ = concat_lists($1, declarator_1_struct_union($4)); } ; notype_struct_declarator: notype_declarator | notype_declarator T_COLON constant_expr { /* C99 6.7.2.1 */ - $$ = bitfield($1, to_int_constant($3, true)); + $$ = set_bit_field_width($1, to_int_constant($3, true)); } | { symtyp = FVFT; } T_COLON constant_expr { /* C99 6.7.2.1 */ - $$ = bitfield(NULL, to_int_constant($3, true)); + $$ = set_bit_field_width(NULL, to_int_constant($3, true)); } ; type_struct_declarator: type_declarator | type_declarator T_COLON constant_expr { - $$ = bitfield($1, to_int_constant($3, true)); + $$ = set_bit_field_width($1, to_int_constant($3, true)); } | { symtyp = FVFT; } T_COLON constant_expr { - $$ = bitfield(NULL, to_int_constant($3, true)); + $$ = set_bit_field_width(NULL, to_int_constant($3, true)); } ; /* K&R ---, C90 6.5.2.2, C99 6.7.2.2, C11 6.7.2.2 */ enum_specifier: /* C99 6.7.2.2 */ enum gcc_attribute_specifier_list_opt identifier_sym { - $$ = mktag($3, ENUM, false, false); + $$ = make_tag_type($3, ENUM, false, false); } | enum gcc_attribute_specifier_list_opt identifier_sym { - dcs->d_tagtyp = mktag($3, ENUM, true, false); + dcs->d_tagtyp = make_tag_type($3, ENUM, true, false); } enum_declaration /*gcc_attribute_specifier_list_opt*/ { $$ = complete_tag_enum(dcs->d_tagtyp, $5); } | enum gcc_attribute_specifier_list_opt { - dcs->d_tagtyp = mktag(NULL, ENUM, true, false); + dcs->d_tagtyp = make_tag_type(NULL, ENUM, true, false); } enum_declaration /*gcc_attribute_specifier_list_opt*/ { $$ = complete_tag_enum(dcs->d_tagtyp, $4); } @@ -1077,7 +1077,7 @@ enums_with_opt_comma: /* helper for C99 enumerator_list: /* C99 6.7.2.2 */ enumerator | enumerator_list T_COMMA enumerator { - $$ = lnklst($1, $3); + $$ = concat_lists($1, $3); } | error { $$ = NULL; @@ -1341,7 +1341,7 @@ identifier_list: /* C99 6.7.5 */ $$ = old_style_function_name(getsym($1)); } | identifier_list T_COMMA T_NAME { - $$ = lnklst($1, old_style_function_name(getsym($3))); + $$ = concat_lists($1, old_style_function_name(getsym($3))); } | identifier_list error ; @@ -1460,7 +1460,7 @@ vararg_parameter_type_list: /* specific parameter_type_list: parameter_declaration | parameter_type_list T_COMMA parameter_declaration { - $$ = lnklst($1, $3); + $$ = concat_lists($1, $3); } ; Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.296 src/usr.bin/xlint/lint1/decl.c:1.297 --- src/usr.bin/xlint/lint1/decl.c:1.296 Sun Aug 28 08:41:06 2022 +++ src/usr.bin/xlint/lint1/decl.c Sun Aug 28 10:43:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.296 2022/08/28 08:41:06 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.297 2022/08/28 10:43:18 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: decl.c,v 1.296 2022/08/28 08:41:06 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.297 2022/08/28 10:43:18 rillig Exp $"); #endif #include <sys/param.h> @@ -57,17 +57,17 @@ static type_t typetab[NTSPEC]; int enumval; /* - * pointer to top element of a stack which contains information local + * pointer to innermost element of a stack which contains information local * to nested declarations */ dinfo_t *dcs; -static type_t *tdeferr(type_t *, tspec_t); -static void settdsym(type_t *, sym_t *); +static type_t *typedef_error(type_t *, tspec_t); +static void set_first_typedef(type_t *, sym_t *); static void dcs_align(unsigned int, unsigned int); -static sym_t *newtag(sym_t *, scl_t, bool, bool); -static bool eqargs(const type_t *, const type_t *, bool *); -static bool mnoarg(const type_t *, bool *); +static sym_t *new_tag(sym_t *, scl_t, bool, bool); +static bool eq_prototype_args(const type_t *, const type_t *, bool *); +static bool matches_no_arg_function(const type_t *, bool *); static bool check_old_style_definition(sym_t *, sym_t *); static bool check_prototype_declaration(sym_t *, sym_t *); static sym_t *new_style_function(sym_t *); @@ -219,8 +219,7 @@ is_incomplete(const type_t *tp) } /* - * Remember the storage class of the current declaration in dcs->d_scl - * (the top element of the declaration stack) and detect multiple + * Remember the storage class of the current declaration and detect multiple * storage classes. */ void @@ -327,7 +326,7 @@ dcs_add_type(type_t *tp) if (dcs->d_type != NULL && dcs->d_type->t_typedef) { /* something like "typedef int a; a long ..." */ - dcs->d_type = tdeferr(dcs->d_type, t); + dcs->d_type = typedef_error(dcs->d_type, t); return; } @@ -395,7 +394,7 @@ merge_signedness(tspec_t t, tspec_t s) * and other specifiers (except struct, union, enum, typedef name) */ static type_t * -tdeferr(type_t *td, tspec_t t) +typedef_error(type_t *td, tspec_t t) { tspec_t t2; @@ -460,7 +459,7 @@ tdeferr(type_t *td, tspec_t t) * if the tag is unnamed. */ static void -settdsym(type_t *tp, sym_t *sym) +set_first_typedef(type_t *tp, sym_t *sym) { tspec_t t; @@ -474,7 +473,7 @@ settdsym(type_t *tp, sym_t *sym) } static unsigned int -bitfieldsize(sym_t **mem) +bit_field_size(sym_t **mem) { unsigned int len = (*mem)->s_type->t_flen; while (*mem != NULL && (*mem)->s_type->t_bitfield) { @@ -485,7 +484,7 @@ bitfieldsize(sym_t **mem) } static void -setpackedsize(type_t *tp) +set_packed_size(type_t *tp) { struct_or_union *sp; sym_t *mem; @@ -500,7 +499,7 @@ setpackedsize(type_t *tp) unsigned int x; if (mem->s_type->t_bitfield) { - sp->sou_size_in_bits += bitfieldsize(&mem); + sp->sou_size_in_bits += bit_field_size(&mem); if (mem == NULL) break; } @@ -524,7 +523,7 @@ dcs_add_packed(void) if (dcs->d_type == NULL) dcs->d_packed = true; else - setpackedsize(dcs->d_type); + set_packed_size(dcs->d_type); } void @@ -915,7 +914,7 @@ alignment_in_bits(const type_t *tp) * struct/union/enum elements and parameters. */ sym_t * -lnklst(sym_t *l1, sym_t *l2) +concat_lists(sym_t *l1, sym_t *l2) { sym_t *l; @@ -1219,7 +1218,7 @@ dcs_align(unsigned int al, unsigned int * Remember the width of the field in its type structure. */ sym_t * -bitfield(sym_t *dsym, int len) +set_bit_field_width(sym_t *dsym, int len) { if (dsym == NULL) { @@ -1682,7 +1681,7 @@ old_style_function_name(sym_t *sym) * semi is true if the following token is T_SEMI */ type_t * -mktag(sym_t *tag, tspec_t kind, bool decl, bool semi) +make_tag_type(sym_t *tag, tspec_t kind, bool decl, bool semi) { scl_t scl; type_t *tp; @@ -1698,7 +1697,7 @@ mktag(sym_t *tag, tspec_t kind, bool dec if (tag != NULL) { if (tag->s_scl != NOSCL) { - tag = newtag(tag, scl, decl, semi); + tag = new_tag(tag, scl, decl, semi); } else { /* a new tag, no empty declaration */ dcs->d_enclosing->d_nonempty_decl = true; @@ -1751,7 +1750,7 @@ mktag(sym_t *tag, tspec_t kind, bool dec * semi is true if T_SEMI follows */ static sym_t * -newtag(sym_t *tag, scl_t scl, bool decl, bool semi) +new_tag(sym_t *tag, scl_t scl, bool decl, bool semi) { if (tag->s_block_level < block_level) { @@ -1848,7 +1847,7 @@ complete_tag_struct_or_union(type_t *tp, sp->sou_align_in_bits = dcs->d_sou_align_in_bits; sp->sou_first_member = fmem; if (tp->t_packed) - setpackedsize(tp); + set_packed_size(tp); else sp->sou_size_in_bits = dcs->d_offset_in_bits; @@ -1863,7 +1862,7 @@ complete_tag_struct_or_union(type_t *tp, if (mem->u.s_member.sm_sou_type == NULL) { mem->u.s_member.sm_sou_type = sp; if (mem->s_type->t_bitfield) { - sp->sou_size_in_bits += bitfieldsize(&mem); + sp->sou_size_in_bits += bit_field_size(&mem); if (mem == NULL) break; } @@ -2066,7 +2065,7 @@ declare_extern(sym_t *dsym, bool initflg if (dsym->s_scl == TYPEDEF) { dsym->s_type = block_dup_type(dsym->s_type); dsym->s_type->t_typedef = true; - settdsym(dsym->s_type, dsym); + set_first_typedef(dsym->s_type, dsym); } } @@ -2199,7 +2198,7 @@ qualifiers_correspond(const type_t *tp1, } bool -eqptrtype(const type_t *tp1, const type_t *tp2, bool ignqual) +eq_pointer_type(const type_t *tp1, const type_t *tp2, bool ignqual) { if (tp1->t_tspec != VOID && tp2->t_tspec != VOID) return false; @@ -2265,13 +2264,13 @@ eqtype(const type_t *tp1, const type_t * /* don't check prototypes for traditional */ if (t == FUNC && allow_c90) { if (tp1->t_proto && tp2->t_proto) { - if (!eqargs(tp1, tp2, dowarn)) + if (!eq_prototype_args(tp1, tp2, dowarn)) return false; } else if (tp1->t_proto) { - if (!mnoarg(tp1, dowarn)) + if (!matches_no_arg_function(tp1, dowarn)) return false; } else if (tp2->t_proto) { - if (!mnoarg(tp2, dowarn)) + if (!matches_no_arg_function(tp2, dowarn)) return false; } } @@ -2289,7 +2288,7 @@ eqtype(const type_t *tp1, const type_t * * Compares the parameter types of two prototypes. */ static bool -eqargs(const type_t *tp1, const type_t *tp2, bool *dowarn) +eq_prototype_args(const type_t *tp1, const type_t *tp2, bool *dowarn) { sym_t *a1, *a2; @@ -2313,9 +2312,9 @@ eqargs(const type_t *tp1, const type_t * } /* - * mnoarg() (matches functions with no argument type information) - * returns whether all parameters of a prototype are compatible with - * an old style function declaration. + * 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 has a fixed number of parameters * 2. no parameter is of type float @@ -2323,7 +2322,7 @@ eqargs(const type_t *tp1, const type_t * * is applied on it */ static bool -mnoarg(const type_t *tp, bool *dowarn) +matches_no_arg_function(const type_t *tp, bool *dowarn) { sym_t *arg; tspec_t t; @@ -2811,7 +2810,7 @@ declare_local(sym_t *dsym, bool initflg) if (dsym->s_scl == TYPEDEF) { dsym->s_type = block_dup_type(dsym->s_type); dsym->s_type->t_typedef = true; - settdsym(dsym->s_type, dsym); + set_first_typedef(dsym->s_type, dsym); } /* Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.166 src/usr.bin/xlint/lint1/externs1.h:1.167 --- src/usr.bin/xlint/lint1/externs1.h:1.166 Sun Aug 28 08:41:06 2022 +++ src/usr.bin/xlint/lint1/externs1.h Sun Aug 28 10:43:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.166 2022/08/28 08:41:06 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.167 2022/08/28 10:43:18 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -201,10 +201,10 @@ extern void dcs_begin_type(void); extern void dcs_end_type(void); extern int length_in_bits(const type_t *, const char *); extern unsigned int alignment_in_bits(const type_t *); -extern sym_t *lnklst(sym_t *, sym_t *); +extern sym_t *concat_lists(sym_t *, sym_t *); extern void check_type(sym_t *); extern sym_t *declarator_1_struct_union(sym_t *); -extern sym_t *bitfield(sym_t *, int); +extern sym_t *set_bit_field_width(sym_t *, int); extern qual_ptr *merge_qualified_pointer(qual_ptr *, qual_ptr *); extern sym_t *add_pointer(sym_t *, qual_ptr *); extern sym_t *add_array(sym_t *, bool, int); @@ -212,7 +212,7 @@ extern sym_t *add_function(sym_t *, sym_ extern void check_function_definition(sym_t *, bool); extern sym_t *declarator_name(sym_t *); extern sym_t *old_style_function_name(sym_t *); -extern type_t *mktag(sym_t *, tspec_t, bool, bool); +extern type_t *make_tag_type(sym_t *, tspec_t, bool, bool); extern const char *storage_class_name(scl_t); extern type_t *complete_tag_struct_or_union(type_t *, sym_t *); extern type_t *complete_tag_enum(type_t *, sym_t *); @@ -220,7 +220,7 @@ extern sym_t *enumeration_constant(sym_t extern void declare(sym_t *, bool, sbuf_t *); extern void copy_usage_info(sym_t *, sym_t *); extern bool check_redeclaration(sym_t *, bool *); -extern bool eqptrtype(const type_t *, const type_t *, bool); +extern bool eq_pointer_type(const type_t *, const type_t *, bool); extern bool eqtype(const type_t *, const type_t *, bool, bool, bool *); extern void complete_type(sym_t *, sym_t *); extern sym_t *declare_argument(sym_t *, bool); Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.477 src/usr.bin/xlint/lint1/tree.c:1.478 --- src/usr.bin/xlint/lint1/tree.c:1.477 Thu Aug 25 19:03:47 2022 +++ src/usr.bin/xlint/lint1/tree.c Sun Aug 28 10:43:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.477 2022/08/25 19:03:47 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.478 2022/08/28 10:43:18 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: tree.c,v 1.477 2022/08/25 19:03:47 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.478 2022/08/28 10:43:18 rillig Exp $"); #endif #include <float.h> @@ -1311,7 +1311,7 @@ typeok_colon_pointer(const mod_t *mp, co return; } - if (eqptrtype(lstp, rstp, true)) + if (eq_pointer_type(lstp, rstp, true)) return; if (!eqtype(lstp, rstp, true, false, NULL)) warn_incompatible_pointers(mp, ltp, rtp); Index: src/usr.bin/xlint/lint2/chk.c diff -u src/usr.bin/xlint/lint2/chk.c:1.49 src/usr.bin/xlint/lint2/chk.c:1.50 --- src/usr.bin/xlint/lint2/chk.c:1.49 Mon May 30 23:27:45 2022 +++ src/usr.bin/xlint/lint2/chk.c Sun Aug 28 10:43:19 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: chk.c,v 1.49 2022/05/30 23:27:45 rillig Exp $ */ +/* $NetBSD: chk.c,v 1.50 2022/08/28 10:43:19 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: chk.c,v 1.49 2022/05/30 23:27:45 rillig Exp $"); +__RCSID("$NetBSD: chk.c,v 1.50 2022/08/28 10:43:19 rillig Exp $"); #endif #include <ctype.h> @@ -66,8 +66,8 @@ static void inconarg(const hte_t *, fcal static void tofewarg(const hte_t *, fcall_t *); static void tomanyarg(const hte_t *, fcall_t *); static bool eqtype(type_t *, type_t *, bool, bool, bool, bool *); -static bool eqargs(type_t *, type_t *, bool *); -static bool mnoarg(type_t *, bool *); +static bool eq_prototype_args(type_t *, type_t *, bool *); +static bool matches_no_arg_function(type_t *, bool *); /* @@ -1308,13 +1308,13 @@ eqtype(type_t *tp1, type_t *tp2, bool ig if (t == FUNC) { if (tp1->t_proto && tp2->t_proto) { - if (!eqargs(tp1, tp2, dowarn)) + if (!eq_prototype_args(tp1, tp2, dowarn)) return false; } else if (tp1->t_proto) { - if (!mnoarg(tp1, dowarn)) + if (!matches_no_arg_function(tp1, dowarn)) return false; } else if (tp2->t_proto) { - if (!mnoarg(tp2, dowarn)) + if (!matches_no_arg_function(tp2, dowarn)) return false; } } @@ -1334,7 +1334,7 @@ eqtype(type_t *tp1, type_t *tp2, bool ig * Compares arguments of two prototypes */ static bool -eqargs(type_t *tp1, type_t *tp2, bool *dowarn) +eq_prototype_args(type_t *tp1, type_t *tp2, bool *dowarn) { type_t **a1, **a2; @@ -1358,17 +1358,17 @@ eqargs(type_t *tp1, type_t *tp2, bool *d } /* - * mnoarg() (matches functions with no argument type information) - * returns true if all parameters of a prototype are compatible with - * and old style function declaration. - * This is the case if following conditions are met: + * 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 * 2. no parameter is of type float * 3. no parameter is converted to another type if integer promotion * is applied on it */ static bool -mnoarg(type_t *tp, bool *dowarn) +matches_no_arg_function(type_t *tp, bool *dowarn) { type_t **arg; tspec_t t;