Module Name: src Committed By: rillig Date: Sat Jan 16 02:40:03 UTC 2021
Modified Files: src/usr.bin/xlint/common: emit.c externs.h lint.h tyname.c src/usr.bin/xlint/lint1: cgram.y decl.c emit1.c externs1.h func.c init.c lint1.h main1.c mem1.c oper.c scan.l tree.c src/usr.bin/xlint/lint2: chk.c externs2.h hash.c main2.c msg.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: replace 0 and 1 with false and true, where appropriate Change in behavior: Passing the option -h exactly 4294967296 times or any multiple thereof is no longer equivalent to passing it never at all, it is now equivalent to passing it once. See main2.c, hflag++ for the actual change. Other than that, no functional change intended. A very large portion of the code already conformed to the requirements of the strict bool mode. The only missing thing was using the constant literals false and true instead of 0 and 1. For sure there are some integer literals left that can be converted. For now, all literals that appeared in the form " = 0" or " = 1" have been replaced. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.139 -r1.140 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.121 -r1.122 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/lint1/oper.c cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/scan.l cvs rdiff -u -r1.153 -r1.154 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.33 -r1.34 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint2/externs2.h cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/lint2/hash.c \ src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint2/msg.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.53 -r1.54 src/usr.bin/xlint/xlint/xlint.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/emit.c diff -u src/usr.bin/xlint/common/emit.c:1.9 src/usr.bin/xlint/common/emit.c:1.10 --- src/usr.bin/xlint/common/emit.c:1.9 Wed Dec 30 11:47:15 2020 +++ src/usr.bin/xlint/common/emit.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.9 2020/12/30 11:47:15 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.10 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit.c,v 1.9 2020/12/30 11:47:15 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.10 2021/01/16 02:40:02 rillig Exp $"); #endif #include <ctype.h> @@ -139,7 +139,7 @@ void outqchar(int c) { - if (isprint(c) && c != '\\' && c != '"' && c != '\'') { + if (ch_isprint(c) && c != '\\' && c != '"' && c != '\'') { outchar(c); } else { outchar('\\'); Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.13 src/usr.bin/xlint/common/externs.h:1.14 --- src/usr.bin/xlint/common/externs.h:1.13 Tue Jan 12 20:42:00 2021 +++ src/usr.bin/xlint/common/externs.h Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.13 2021/01/12 20:42:00 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.14 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -34,7 +34,7 @@ /* * main[12].c */ -extern int pflag; +extern bool pflag; /* Treat _Bool as incompatible to all other scalar types. */ extern bool Tflag; @@ -47,7 +47,7 @@ extern void inittyp(void); * tyname.c */ extern const char *type_name(const type_t *); -extern int sametype(const type_t *, const type_t *); +extern bool sametype(const type_t *, const type_t *); extern const char *tspec_name(tspec_t); /* Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.24 src/usr.bin/xlint/common/lint.h:1.25 --- src/usr.bin/xlint/common/lint.h:1.24 Sun Jan 10 00:05:45 2021 +++ src/usr.bin/xlint/common/lint.h Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.24 2021/01/10 00:05:45 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.25 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,6 +38,7 @@ #endif #include <sys/types.h> +#include <ctype.h> #include <err.h> #include <inttypes.h> #include <stdbool.h> @@ -137,3 +138,12 @@ typedef struct ob { typedef struct type type_t; #include "externs.h" + +static inline bool +ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; } +static inline bool +ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; } +static inline bool +ch_isprint(char ch) { return isprint((unsigned char)ch) != 0; } +static inline bool +ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; } Index: src/usr.bin/xlint/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.22 src/usr.bin/xlint/common/tyname.c:1.23 --- src/usr.bin/xlint/common/tyname.c:1.22 Mon Jan 4 22:26:50 2021 +++ src/usr.bin/xlint/common/tyname.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.22 2021/01/04 22:26:50 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.23 2021/01/16 02:40:02 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.22 2021/01/04 22:26:50 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.23 2021/01/16 02:40:02 rillig Exp $"); #endif #include <limits.h> @@ -192,13 +192,13 @@ tspec_name(tspec_t t) } } -int +bool sametype(const type_t *t1, const type_t *t2) { tspec_t t; if (t1->t_tspec != t2->t_tspec) - return 0; + return false; /* Ignore const/void */ @@ -231,7 +231,7 @@ sametype(const type_t *t1, const type_t return 1; case ARRAY: if (t1->t_dim != t2->t_dim) - return 0; + return false; /*FALLTHROUGH*/ case PTR: return sametype(t1->t_subt, t2->t_subt); @@ -240,7 +240,7 @@ sametype(const type_t *t1, const type_t return strcmp(t1->t_enum->etag->s_name, t2->t_enum->etag->s_name) == 0; #else - return 1; + return true; #endif case STRUCT: case UNION: @@ -248,11 +248,11 @@ sametype(const type_t *t1, const type_t return strcmp(t1->t_str->stag->s_name, t2->t_str->stag->s_name) == 0; #else - return 1; + return true; #endif default: LERROR("tyname(%d)", t); - return 0; + return false; } } Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.139 src/usr.bin/xlint/lint1/cgram.y:1.140 --- src/usr.bin/xlint/lint1/cgram.y:1.139 Tue Jan 12 20:42:01 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sat Jan 16 02:40:02 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.139 2021/01/12 20:42:01 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.140 2021/01/16 02:40:02 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.139 2021/01/12 20:42:01 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.140 2021/01/16 02:40:02 rillig Exp $"); #endif #include <limits.h> @@ -426,7 +426,7 @@ function_definition: /* C99 6.9.1 */ blklev++; pushdecl(ARG); if (lwarn == LWARN_NONE) - $1->s_used = 1; + $1->s_used = true; } arg_declaration_list_opt { popdecl(); blklev--; @@ -598,9 +598,9 @@ type_attribute_spec_list: type_attribute: T_ATTRIBUTE T_LPAREN T_LPAREN { - attron = 1; + attron = true; } type_attribute_spec_list { - attron = 0; + attron = false; } T_RPAREN T_RPAREN | T_PACKED { addpacked(); @@ -1194,9 +1194,9 @@ type_qualifier: T_QUAL { $$ = xcalloc(1, sizeof (pqinf_t)); if ($1 == CONST) { - $$->p_const = 1; + $$->p_const = true; } else { - $$->p_volatile = 1; + $$->p_volatile = true; } } ; @@ -1234,7 +1234,7 @@ abs_decl_param_list: $$ = NULL; } | abs_decl_lparn vararg_parameter_type_list T_RPAREN { - dcs->d_proto = 1; + dcs->d_proto = true; $$ = $2; } | abs_decl_lparn error T_RPAREN { @@ -1254,7 +1254,7 @@ vararg_parameter_type_list: $$ = $1; } | parameter_type_list T_COMMA T_ELLIPSE { - dcs->d_vararg = 1; + dcs->d_vararg = true; $$ = $1; } | T_ELLIPSE { @@ -1265,7 +1265,7 @@ vararg_parameter_type_list: /* ANSI C requires formal parameter before '...' */ warning(84); } - dcs->d_vararg = 1; + dcs->d_vararg = true; $$ = NULL; } ; @@ -1480,7 +1480,7 @@ non_expr_statement: | selection_statement | iteration_statement | jump_statement { - ftflg = 0; + ftflg = false; } | asm_statement @@ -1500,16 +1500,16 @@ label: } | T_CASE constant T_COLON { case_label($2); - ftflg = 1; + ftflg = true; } | T_CASE constant T_ELLIPSE constant T_COLON { /* XXX: We don't fill all cases */ case_label($2); - ftflg = 1; + ftflg = true; } | T_DEFAULT T_COLON { default_label(); - ftflg = 1; + ftflg = true; } ; @@ -1544,7 +1544,7 @@ compound_statement_rbrace: freeblk(); mblklev--; blklev--; - ftflg = 0; + ftflg = false; } ; @@ -1559,10 +1559,10 @@ statement_list: expr_statement: expr T_SEMI { expr($1, 0, 0, 0); - ftflg = 0; + ftflg = false; } | T_SEMI { - ftflg = 0; + ftflg = false; } ; @@ -1575,10 +1575,10 @@ expr_statement_val: expr T_SEMI { /* XXX: We should really do that only on the last name */ if ($1->tn_op == NAME) - $1->tn_sym->s_used = 1; + $1->tn_sym->s_used = true; $$ = $1; expr($1, 0, 0, 0); - ftflg = 0; + ftflg = false; } | non_expr_statement { $$ = getnode(); @@ -1672,7 +1672,7 @@ iteration_statement: /* C99 6.8.5 */ } | do_statement do_while_expr { do2($2); - ftflg = 0; + ftflg = false; } | do error { CLRWFLGS(__FILE__, __LINE__); @@ -1867,7 +1867,7 @@ term: } | T_LPAREN expr T_RPAREN { if ($2 != NULL) - $2->tn_parenthesized = 1; + $2->tn_parenthesized = true; $$ = $2; } | T_LPAREN compound_statement_lbrace declaration_list @@ -2142,7 +2142,7 @@ idecl(sym_t *decl, int initflg, sbuf_t * { char *s; - initerr = 0; + initerr = false; initsym = decl; switch (dcs->d_ctx) { Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.121 src/usr.bin/xlint/lint1/decl.c:1.122 --- src/usr.bin/xlint/lint1/decl.c:1.121 Mon Jan 11 19:29:49 2021 +++ src/usr.bin/xlint/lint1/decl.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.121 2021/01/11 19:29:49 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.122 2021/01/16 02:40: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: decl.c,v 1.121 2021/01/11 19:29:49 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.122 2021/01/16 02:40:02 rillig Exp $"); #endif #include <sys/param.h> @@ -66,17 +66,17 @@ static type_t *tdeferr(type_t *, tspec_t static void settdsym(type_t *, sym_t *); static tspec_t merge_type_specifiers(tspec_t, tspec_t); static void align(int, int); -static sym_t *newtag(sym_t *, scl_t, int, int); -static int eqargs(const type_t *, const type_t *, int *); -static int mnoarg(const type_t *, int *); -static int check_old_style_definition(sym_t *, sym_t *); -static int check_prototype_declaration(sym_t *, sym_t *); +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 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 *, sym_t *); static void old_style_function(sym_t *, sym_t *); static void declare_external_in_block(sym_t *); -static int check_init(sym_t *); -static void check_argument_usage(int, sym_t *); -static void check_variable_usage(int, sym_t *); +static bool check_init(sym_t *); +static void check_argument_usage(bool, sym_t *); +static void check_variable_usage(bool, sym_t *); static void check_label_usage(sym_t *); static void check_tag_usage(sym_t *); static void check_global_variable(const sym_t *); @@ -171,7 +171,7 @@ tduptyp(const type_t *tp) * Returns 1 if the argument is void or an incomplete array, * struct, union or enum type. */ -int +bool incompl(const type_t *tp) { tspec_t t; @@ -192,7 +192,7 @@ incompl(const type_t *tp) * Mark an array, struct, union or enum type as complete or incomplete. */ void -setcomplete(type_t *tp, int complete) +setcomplete(type_t *tp, bool complete) { tspec_t t; @@ -219,7 +219,7 @@ add_storage_class(scl_t sc) if (dcs->d_inline) /* duplicate '%s' */ warning(10, "inline"); - dcs->d_inline = 1; + dcs->d_inline = true; return; } if (dcs->d_type != NULL || dcs->d_atyp != NOTSPEC || @@ -234,7 +234,7 @@ add_storage_class(scl_t sc) * multiple storage classes. An error will be reported in * deftyp(). */ - dcs->d_mscl = 1; + dcs->d_mscl = true; } } @@ -282,7 +282,7 @@ add_type(type_t *tp) * remember that an error must be reported in * deftyp(). */ - dcs->d_terr = 1; + dcs->d_terr = true; dcs->d_atyp = dcs->d_lmod = dcs->d_smod = NOTSPEC; } dcs->d_type = tp; @@ -294,7 +294,7 @@ add_type(type_t *tp) * something like "struct a int" * struct/union/enum with anything else is not allowed */ - dcs->d_terr = 1; + dcs->d_terr = true; return; } @@ -334,7 +334,7 @@ add_type(type_t *tp) * more than one "signed" and/or "unsigned"; print * an error in deftyp() */ - dcs->d_terr = 1; + dcs->d_terr = true; dcs->d_smod = t; } else if (t == SHORT || t == LONG || t == QUAD) { /* @@ -343,17 +343,17 @@ add_type(type_t *tp) */ if (dcs->d_lmod != NOTSPEC) /* more than one, print error in deftyp() */ - dcs->d_terr = 1; + dcs->d_terr = true; dcs->d_lmod = t; } else if (t == FLOAT || t == DOUBLE) { if (dcs->d_lmod == NOTSPEC || dcs->d_lmod == LONG) { if (dcs->d_cmod != NOTSPEC || (t == FLOAT && dcs->d_lmod == LONG)) - dcs->d_terr = 1; + dcs->d_terr = true; dcs->d_cmod = t; } else { if (dcs->d_atyp != NOTSPEC) - dcs->d_terr = 1; + dcs->d_terr = true; dcs->d_atyp = t; } } else if (t == PTR) { @@ -365,7 +365,7 @@ add_type(type_t *tp) */ if (dcs->d_atyp != NOTSPEC) /* more than one, print error in deftyp() */ - dcs->d_terr = 1; + dcs->d_terr = true; dcs->d_atyp = t; } } @@ -390,7 +390,7 @@ tdeferr(type_t *td, tspec_t t) /* modifying typedef with '%s'; only ... */ warning(5, ttab[t].tt_name); td = duptyp(gettyp(merge_type_specifiers(t2, t))); - td->t_typedef = 1; + td->t_typedef = true; return td; } break; @@ -399,7 +399,7 @@ tdeferr(type_t *td, tspec_t t) /* modifying typedef with '%s'; only qualifiers ... */ warning(5, "short"); td = duptyp(gettyp(t2 == INT ? SHORT : USHORT)); - td->t_typedef = 1; + td->t_typedef = true; return td; } break; @@ -424,7 +424,7 @@ tdeferr(type_t *td, tspec_t t) td = gettyp(LCOMPLEX); } td = duptyp(td); - td->t_typedef = 1; + td->t_typedef = true; return td; } break; @@ -463,7 +463,7 @@ tdeferr(type_t *td, tspec_t t) /* Anything other is not accepted. */ - dcs->d_terr = 1; + dcs->d_terr = true; return td; } @@ -494,7 +494,7 @@ static size_t bitfieldsize(sym_t **mem) { size_t len = (*mem)->s_type->t_flen; - while (*mem && (*mem)->s_type->t_bitfield) { + while (*mem != NULL && (*mem)->s_type->t_bitfield) { len += (*mem)->s_type->t_flen; *mem = (*mem)->s_next; } @@ -536,7 +536,7 @@ void addpacked(void) { if (dcs->d_type == NULL) - dcs->d_packed = 1; + dcs->d_packed = true; else setpackedsize(dcs->d_type); } @@ -544,7 +544,7 @@ addpacked(void) void add_attr_used(void) { - dcs->d_used = 1; + dcs->d_used = true; } /* @@ -564,7 +564,7 @@ add_qualifier(tqual_t q) /* duplicate '%s' */ warning(10, "const"); } - dcs->d_const = 1; + dcs->d_const = true; } else { if (q == THREAD) return; @@ -573,7 +573,7 @@ add_qualifier(tqual_t q) /* duplicate '%s' */ warning(10, "volatile"); } - dcs->d_volatile = 1; + dcs->d_volatile = true; } } @@ -689,7 +689,7 @@ setasm(void) dinfo_t *di; for (di = dcs; di != NULL; di = di->d_next) - di->d_asm = 1; + di->d_asm = true; } /* @@ -703,11 +703,13 @@ clrtyp(void) dcs->d_atyp = dcs->d_cmod = dcs->d_smod = dcs->d_lmod = NOTSPEC; dcs->d_scl = NOSCL; dcs->d_type = NULL; - dcs->d_const = dcs->d_volatile = 0; - dcs->d_inline = 0; - dcs->d_mscl = dcs->d_terr = 0; - dcs->d_nedecl = 0; - dcs->d_notyp = 0; + dcs->d_const = false; + dcs->d_volatile = false; + dcs->d_inline = false; + dcs->d_mscl = false; + dcs->d_terr = false; + dcs->d_nedecl = false; + dcs->d_notyp = false; } /* @@ -735,7 +737,7 @@ deftyp(void) #endif if (t == NOTSPEC && s == NOTSPEC && l == NOTSPEC && c == NOTSPEC && tp == NULL) - dcs->d_notyp = 1; + dcs->d_notyp = true; if (t == NOTSPEC && s == NOTSPEC && (l == NOTSPEC || l == LONG) && tp == NULL) t = c; @@ -759,7 +761,7 @@ deftyp(void) break; case CHAR: if (l != NOTSPEC) { - dcs->d_terr = 1; + dcs->d_terr = true; l = NOTSPEC; } break; @@ -799,7 +801,7 @@ deftyp(void) LERROR("deftyp(%s)", tspec_name(t)); } if (t != INT && t != CHAR && (s != NOTSPEC || l != NOTSPEC)) { - dcs->d_terr = 1; + dcs->d_terr = true; l = s = NOTSPEC; } if (l != NOTSPEC) @@ -887,7 +889,7 @@ length(const type_t *tp, const char *nam int elem, elsz; elem = 1; - while (tp && tp->t_tspec == ARRAY) { + while (tp != NULL && tp->t_tspec == ARRAY) { elem *= tp->t_dim; tp = tp->t_subt; } @@ -931,7 +933,7 @@ getbound(const type_t *tp) size_t a; tspec_t t; - while (tp && tp->t_tspec == ARRAY) + while (tp != NULL && tp->t_tspec == ARRAY) tp = tp->t_subt; if (tp == NULL) @@ -1063,7 +1065,7 @@ check_type(sym_t *sym) if (tp->t_const || tp->t_volatile) { /* inappropriate qualifiers with 'void' */ warning(69); - tp->t_const = tp->t_volatile = 0; + tp->t_const = tp->t_volatile = false; } } tpp = &tp->t_subt; @@ -1149,7 +1151,7 @@ declarator_1_struct_union(sym_t *dsym) /* illegal use of bit-field */ error(41); dsym->s_type->t_bitfield = false; - dsym->s_bitfield = 0; + dsym->s_bitfield = false; } } else if (t == FUNC) { /* function illegal in structure or union */ @@ -1240,7 +1242,7 @@ bitfield(sym_t *dsym, int len) dsym->s_type = duptyp(dsym->s_type); dsym->s_type->t_bitfield = true; dsym->s_type->t_flen = len; - dsym->s_bitfield = 1; + dsym->s_bitfield = true; return dsym; } @@ -1267,14 +1269,14 @@ merge_pointers_and_qualifiers(pqinf_t *p /* duplicate '%s' */ warning(10, "const"); } - p1->p_const = 1; + p1->p_const = true; } if (p2->p_volatile) { if (p1->p_volatile) { /* duplicate '%s' */ warning(10, "volatile"); } - p1->p_volatile = 1; + p1->p_volatile = true; } free(p2); return p1; @@ -1296,7 +1298,7 @@ add_pointer(sym_t *decl, pqinf_t *pi) pqinf_t *npi; tpp = &decl->s_type; - while (*tpp && *tpp != dcs->d_type) + while (*tpp != NULL && *tpp != dcs->d_type) tpp = &(*tpp)->t_subt; if (*tpp == NULL) return decl; @@ -1319,12 +1321,12 @@ add_pointer(sym_t *decl, pqinf_t *pi) * n is the specified dimension */ sym_t * -add_array(sym_t *decl, int dim, int n) +add_array(sym_t *decl, bool dim, int n) { type_t **tpp, *tp; tpp = &decl->s_type; - while (*tpp && *tpp != dcs->d_type) + while (*tpp != NULL && *tpp != dcs->d_type) tpp = &(*tpp)->t_subt; if (*tpp == NULL) return decl; @@ -1379,7 +1381,7 @@ add_function(sym_t *decl, sym_t *args) } tpp = &decl->s_type; - while (*tpp && *tpp != dcs->d_next->d_type) + while (*tpp != NULL && *tpp != dcs->d_next->d_type) tpp = &(*tpp)->t_subt; if (*tpp == NULL) return decl; @@ -1451,7 +1453,7 @@ old_style_function(sym_t *decl, sym_t *a * we are wrong, it's corrected in check_function_definition(). */ if (args != NULL) { - decl->s_osdef = 1; + decl->s_osdef = true; decl->s_args = args; } } else { @@ -1467,7 +1469,7 @@ old_style_function(sym_t *decl, sym_t *a * error message. */ void -check_function_definition(sym_t *sym, int msg) +check_function_definition(sym_t *sym, bool msg) { if (sym->s_osdef) { @@ -1475,7 +1477,7 @@ check_function_definition(sym_t *sym, in /* incomplete or misplaced function definition */ error(22); } - sym->s_osdef = 0; + sym->s_osdef = false; sym->s_args = NULL; } } @@ -1494,7 +1496,7 @@ declarator_name(sym_t *sym) if (sym->s_scl == NOSCL) { dcs->d_rdcsym = NULL; } else if (sym->s_defarg) { - sym->s_defarg = 0; + sym->s_defarg = false; dcs->d_rdcsym = NULL; } else { dcs->d_rdcsym = sym; @@ -1532,14 +1534,14 @@ declarator_name(sym_t *sym) } break; case PARG: - sym->s_arg = 1; + sym->s_arg = true; /* FALLTHROUGH */ case ARG: if ((sc = dcs->d_scl) == NOSCL) { sc = AUTO; } else { lint_assert(sc == REG); - sym->s_reg = 1; + sym->s_reg = true; sc = AUTO; } sym->s_def = DEF; @@ -1557,7 +1559,7 @@ declarator_name(sym_t *sym) } else if (sc == AUTO || sc == STATIC || sc == TYPEDEF) { sym->s_def = DEF; } else if (sc == REG) { - sym->s_reg = 1; + sym->s_reg = true; sc = AUTO; sym->s_def = DEF; } else { @@ -1596,7 +1598,7 @@ old_style_function_name(sym_t *sym) sym->s_type = gettyp(INT); sym->s_scl = AUTO; sym->s_def = DEF; - sym->s_defarg = sym->s_arg = 1; + sym->s_defarg = sym->s_arg = true; return sym; } @@ -1605,12 +1607,12 @@ old_style_function_name(sym_t *sym) * * tag points to the symbol table entry of the tag * kind is the kind of the tag (STRUCT/UNION/ENUM) - * decl is 1 if the type of the tag will be completed in this declaration + * decl is true if the type of the tag will be completed in this declaration * (the following token is T_LBRACE) - * semi is 1 if the following token is T_SEMI + * semi is true if the following token is T_SEMI */ type_t * -mktag(sym_t *tag, tspec_t kind, int decl, int semi) +mktag(sym_t *tag, tspec_t kind, bool decl, bool semi) { scl_t scl = NOSCL; type_t *tp; @@ -1629,7 +1631,7 @@ mktag(sym_t *tag, tspec_t kind, int decl tag = newtag(tag, scl, decl, semi); } else { /* a new tag, no empty declaration */ - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; if (scl == ENUMTAG && !decl) { if (!tflag && (sflag || pflag)) /* forward reference to enum type */ @@ -1652,7 +1654,7 @@ mktag(sym_t *tag, tspec_t kind, int decl tag->s_blklev = -1; tag->s_type = tp = getblk(sizeof (type_t)); tp->t_packed = dcs->d_packed; - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } if (tp->t_tspec == NOTSPEC) { @@ -1662,7 +1664,7 @@ mktag(sym_t *tag, tspec_t kind, int decl tp->t_str->align = CHAR_SIZE; tp->t_str->stag = tag; } else { - tp->t_isenum = 1; + tp->t_isenum = true; tp->t_enum = getblk(sizeof(*tp->t_enum)); tp->t_enum->etag = tag; } @@ -1673,11 +1675,11 @@ mktag(sym_t *tag, tspec_t kind, int decl /* * Checks all possible cases of tag redeclarations. - * decl is 1 if T_LBRACE follows - * semi is 1 if T_SEMI follows + * decl is true if T_LBRACE follows + * semi is true if T_SEMI follows */ static sym_t * -newtag(sym_t *tag, scl_t scl, int decl, int semi) +newtag(sym_t *tag, scl_t scl, bool decl, bool semi) { if (tag->s_blklev < blklev) { @@ -1694,14 +1696,14 @@ newtag(sym_t *tag, scl_t scl, int decl, warning(45, storage_class_name(tag->s_scl), tag->s_name); } - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } else if (decl) { /* "struct a { ... } " */ if (hflag) /* redefinition hides earlier one: %s */ warning(43, tag->s_name); tag = pushdown(tag); - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } else if (tag->s_scl != scl) { /* base type is really '%s %s' */ warning(45, storage_class_name(tag->s_scl), @@ -1713,7 +1715,7 @@ newtag(sym_t *tag, scl_t scl, int decl, tag->s_name); } tag = pushdown(tag); - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } } else { if (tag->s_scl != scl) { @@ -1721,15 +1723,15 @@ newtag(sym_t *tag, scl_t scl, int decl, error(46, storage_class_name(tag->s_scl)); print_previous_declaration(-1, tag); tag = pushdown(tag); - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } else if (decl && !incompl(tag->s_type)) { /* (%s) tag redeclared */ error(46, storage_class_name(tag->s_scl)); print_previous_declaration(-1, tag); tag = pushdown(tag); - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } else if (semi || decl) { - dcs->d_next->d_nedecl = 1; + dcs->d_next->d_nedecl = true; } } return tag; @@ -1819,13 +1821,13 @@ complete_tag_enum(type_t *tp, sym_t *fme * * sym points to the enumerator * val is the value of the enumerator - * impl is 1 if the value of the enumerator was not explicitly specified. + * impl is true if the value of the enumerator was not explicitly specified. */ sym_t * -enumeration_constant(sym_t *sym, int val, int impl) +enumeration_constant(sym_t *sym, int val, bool impl) { - if (sym->s_scl) { + if (sym->s_scl != NOSCL) { if (sym->s_blklev == blklev) { /* no hflag, because this is illegal!!! */ if (sym->s_arg) { @@ -1865,9 +1867,9 @@ enumeration_constant(sym_t *sym, int val * Process a single external declarator. */ void -decl1ext(sym_t *dsym, int initflg) +decl1ext(sym_t *dsym, bool initflg) { - int dowarn, rval, redec; + bool dowarn, rval, redec; sym_t *rdsym; check_function_definition(dsym, 1); @@ -1887,7 +1889,7 @@ decl1ext(sym_t *dsym, int initflg) if (dcs->d_inline) { if (dsym->s_type->t_tspec == FUNC) { - dsym->s_inline = 1; + dsym->s_inline = true; } else { /* variable declared inline: %s */ warning(268, dsym->s_name); @@ -1917,10 +1919,11 @@ decl1ext(sym_t *dsym, int initflg) if (rdsym->s_osdef && dsym->s_type->t_proto) { redec = check_old_style_definition(rdsym, dsym); } else { - redec = 0; + redec = false; } - if (!redec && !check_redeclaration(dsym, (dowarn = 0, &dowarn))) { + if (!redec && + !check_redeclaration(dsym, (dowarn = false, &dowarn))) { if (dowarn) { if (sflag) @@ -1966,7 +1969,7 @@ decl1ext(sym_t *dsym, int initflg) /* once a function is inline, it remains inline */ if (rdsym->s_inline) - dsym->s_inline = 1; + dsym->s_inline = true; complete_type(dsym, rdsym); @@ -1977,7 +1980,7 @@ decl1ext(sym_t *dsym, int initflg) if (dsym->s_scl == TYPEDEF) { dsym->s_type = duptyp(dsym->s_type); - dsym->s_type->t_typedef = 1; + dsym->s_type->t_typedef = true; settdsym(dsym->s_type, dsym); } @@ -2002,8 +2005,8 @@ copy_usage_info(sym_t *sym, sym_t *rdsym * Otherwise returns 0 and, in some cases of minor problems, prints * a warning. */ -int -check_redeclaration(sym_t *dsym, int *dowarn) +bool +check_redeclaration(sym_t *dsym, bool *dowarn) { sym_t *rsym; @@ -2011,38 +2014,38 @@ check_redeclaration(sym_t *dsym, int *do /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); - return 1; + return true; } if (rsym->s_scl == TYPEDEF) { /* typedef redeclared: %s */ error(89, dsym->s_name); print_previous_declaration(-1, rsym); - return 1; + return true; } if (dsym->s_scl == TYPEDEF) { /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); - return 1; + return true; } if (rsym->s_def == DEF && dsym->s_def == DEF) { /* redefinition of %s */ error(28, dsym->s_name); print_previous_declaration(-1, rsym); - return 1; + return true; } if (!eqtype(rsym->s_type, dsym->s_type, 0, 0, dowarn)) { /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); - return 1; + return true; } if (rsym->s_scl == EXTERN && dsym->s_scl == EXTERN) - return 0; + return false; if (rsym->s_scl == STATIC && dsym->s_scl == STATIC) - return 0; + return false; if (rsym->s_scl == STATIC && dsym->s_def == DECL) - return 0; + return false; if (rsym->s_scl == EXTERN && rsym->s_def == DEF) { /* * All cases except "int a = 1; static int a;" are caught @@ -2051,13 +2054,13 @@ check_redeclaration(sym_t *dsym, int *do /* redeclaration of %s */ error(27, dsym->s_name); print_previous_declaration(-1, rsym); - return 1; + return true; } if (rsym->s_scl == EXTERN) { /* previously declared extern, becomes static: %s */ warning(29, dsym->s_name); print_previous_declaration(-1, rsym); - return 0; + return false; } /* * Now it's one of: @@ -2070,11 +2073,11 @@ check_redeclaration(sym_t *dsym, int *do print_previous_declaration(-1, rsym); } dsym->s_scl = STATIC; - return 0; + return false; } static bool -qualifiers_correspond(const type_t *tp1, const type_t *tp2, int ignqual) +qualifiers_correspond(const type_t *tp1, const type_t *tp2, bool ignqual) { if (tp1->t_const != tp2->t_const && !ignqual && !tflag) return false; @@ -2086,7 +2089,7 @@ qualifiers_correspond(const type_t *tp1, } bool -eqptrtype(const type_t *tp1, const type_t *tp2, int ignqual) +eqptrtype(const type_t *tp1, const type_t *tp2, bool ignqual) { if (tp1->t_tspec != VOID && tp2->t_tspec != VOID) return false; @@ -2107,9 +2110,9 @@ eqptrtype(const type_t *tp1, const type_ * *dowarn set to 1 if an old style function declaration is not * compatible with a prototype */ -int +bool eqtype(const type_t *tp1, const type_t *tp2, - int ignqual, int promot, int *dowarn) + bool ignqual, bool promot, bool *dowarn) { tspec_t t; @@ -2161,7 +2164,7 @@ eqtype(const type_t *tp1, const type_t * tp1 = tp1->t_subt; tp2 = tp2->t_subt; - ignqual = promot = 0; + ignqual = promot = false; } @@ -2171,8 +2174,8 @@ eqtype(const type_t *tp1, const type_t * /* * Compares the parameter types of two prototypes. */ -static int -eqargs(const type_t *tp1, const type_t *tp2, int *dowarn) +static bool +eqargs(const type_t *tp1, const type_t *tp2, bool *dowarn) { sym_t *a1, *a2; @@ -2205,42 +2208,42 @@ eqargs(const type_t *tp1, const type_t * * 3. no parameter is converted to another type if integer promotion * is applied on it */ -static int -mnoarg(const type_t *tp, int *dowarn) +static bool +mnoarg(const type_t *tp, bool *dowarn) { sym_t *arg; tspec_t t; if (tp->t_vararg) { if (dowarn != NULL) - *dowarn = 1; + *dowarn = true; } for (arg = tp->t_args; arg != NULL; arg = arg->s_next) { if ((t = arg->s_type->t_tspec) == FLOAT || t == CHAR || t == SCHAR || t == UCHAR || t == SHORT || t == USHORT) { if (dowarn != NULL) - *dowarn = 1; + *dowarn = true; } } - return 1; + return true; } /* * Compares a prototype declaration with the remembered arguments of * a previous old style function definition. */ -static int +static bool check_old_style_definition(sym_t *rdsym, sym_t *dsym) { sym_t *args, *pargs, *arg, *parg; int narg, nparg, n; - int dowarn, msg; + bool dowarn, msg; args = rdsym->s_args; pargs = dsym->s_type->t_args; - msg = 0; + msg = false; narg = nparg = 0; for (arg = args; arg != NULL; arg = arg->s_next) @@ -2250,15 +2253,15 @@ check_old_style_definition(sym_t *rdsym, if (narg != nparg) { /* prototype does not match old-style definition */ error(63); - msg = 1; + msg = true; goto end; } arg = args; parg = pargs; n = 1; - while (narg--) { - dowarn = 0; + while (narg-- > 0) { + dowarn = false; /* * If it does not match due to promotion and sflag is * not set we print only a warning. @@ -2266,7 +2269,7 @@ check_old_style_definition(sym_t *rdsym, if (!eqtype(arg->s_type, parg->s_type, 1, 1, &dowarn) || dowarn) { /* prototype does not match old style defn., arg #%d */ error(299, n); - msg = 1; + msg = true; } arg = arg->s_next; parg = parg->s_next; @@ -2312,7 +2315,7 @@ complete_type(sym_t *dsym, sym_t *ssym) } else if (dst->t_tspec == FUNC) { if (!dst->t_proto && src->t_proto) { *dstp = dst = duptyp(dst); - dst->t_proto = 1; + dst->t_proto = true; dst->t_args = src->t_args; } } @@ -2325,7 +2328,7 @@ complete_type(sym_t *dsym, sym_t *ssym) * Completes the declaration of a single argument. */ sym_t * -declare_argument(sym_t *sym, int initflg) +declare_argument(sym_t *sym, bool initflg) { tspec_t t; @@ -2337,19 +2340,19 @@ declare_argument(sym_t *sym, int initflg /* redeclaration of formal parameter %s */ error(237, sym->s_name); rmsym(dcs->d_rdcsym); - sym->s_arg = 1; + sym->s_arg = true; } if (!sym->s_arg) { /* declared argument %s is missing */ error(53, sym->s_name); - sym->s_arg = 1; + sym->s_arg = true; } if (initflg) { /* cannot initialize parameter: %s */ error(52, sym->s_name); - initerr = 1; + initerr = true; } if ((t = sym->s_type->t_tspec) == ARRAY) { @@ -2459,7 +2462,8 @@ void check_func_old_style_arguments(void) { sym_t *args, *arg, *pargs, *parg; - int narg, nparg, msg; + int narg, nparg; + bool msg; args = funcsym->s_args; pargs = funcsym->s_type->t_args; @@ -2472,7 +2476,7 @@ check_func_old_style_arguments(void) if (arg->s_defarg) { /* argument type defaults to 'int': %s */ warning(32, arg->s_name); - arg->s_defarg = 0; + arg->s_defarg = false; mark_as_set(arg); } } @@ -2487,7 +2491,7 @@ check_func_old_style_arguments(void) * continue. */ narg = nparg = 0; - msg = 0; + msg = false; for (parg = pargs; parg != NULL; parg = parg->s_next) nparg++; for (arg = args; arg != NULL; arg = arg->s_next) @@ -2495,11 +2499,11 @@ check_func_old_style_arguments(void) if (narg != nparg) { /* parameter mismatch: %d declared, %d defined */ error(51, nparg, narg); - msg = 1; + msg = true; } else { parg = pargs; arg = args; - while (narg--) { + while (narg-- > 0) { msg |= check_prototype_declaration(arg, parg); parg = parg->s_next; arg = arg->s_next; @@ -2510,7 +2514,7 @@ check_func_old_style_arguments(void) print_previous_declaration(285, dcs->d_rdcsym); /* from now on the prototype is valid */ - funcsym->s_osdef = 0; + funcsym->s_osdef = false; funcsym->s_args = NULL; } } @@ -2518,19 +2522,19 @@ check_func_old_style_arguments(void) /* * Checks compatibility of an old style function definition with a previous * prototype declaration. - * Returns 1 if the position of the previous declaration should be reported. + * Returns true if the position of the previous declaration should be reported. */ -static int +static bool check_prototype_declaration(sym_t *arg, sym_t *parg) { type_t *tp, *ptp; - int dowarn, msg; + bool dowarn, msg; tp = arg->s_type; ptp = parg->s_type; - msg = 0; - dowarn = 0; + msg = false; + dowarn = false; if (!eqtype(tp, ptp, 1, 1, &dowarn)) { if (eqtype(tp, ptp, 1, 0, &dowarn)) { @@ -2540,7 +2544,7 @@ check_prototype_declaration(sym_t *arg, } else { /* type does not match prototype: %s */ error(58, arg->s_name); - msg = 1; + msg = true; } } else if (dowarn) { if (sflag) @@ -2549,7 +2553,7 @@ check_prototype_declaration(sym_t *arg, else /* type does not match prototype: %s */ warning(58, arg->s_name); - msg = 1; + msg = true; } return msg; @@ -2559,7 +2563,7 @@ check_prototype_declaration(sym_t *arg, * Completes a single local declaration/definition. */ void -declare_local(sym_t *dsym, int initflg) +declare_local(sym_t *dsym, bool initflg) { /* Correct a mistake done in declarator_name(). */ @@ -2590,7 +2594,7 @@ declare_local(sym_t *dsym, int initflg) */ if (dcs->d_inline) { if (dsym->s_type->t_tspec == FUNC) { - dsym->s_inline = 1; + dsym->s_inline = true; } else { /* variable declared inline: %s */ warning(268, dsym->s_name); @@ -2687,7 +2691,7 @@ declare_local(sym_t *dsym, int initflg) if (dsym->s_scl == TYPEDEF) { dsym->s_type = duptyp(dsym->s_type); - dsym->s_type->t_typedef = 1; + dsym->s_type->t_typedef = true; settdsym(dsym->s_type, dsym); } @@ -2703,7 +2707,7 @@ declare_local(sym_t *dsym, int initflg) static void declare_external_in_block(sym_t *dsym) { - int eqt, dowarn; + bool eqt, dowarn; sym_t *esym; /* look for a symbol with the same name */ @@ -2726,7 +2730,7 @@ declare_external_in_block(sym_t *dsym) return; } - dowarn = 0; + dowarn = false; eqt = eqtype(esym->s_type, dsym->s_type, 0, 0, &dowarn); if (!eqt || dowarn) { @@ -2754,21 +2758,21 @@ declare_external_in_block(sym_t *dsym) * Print an error or a warning if the symbol cannot be initialized due * to type/storage class. Return 1 if an error has been detected. */ -static int +static bool check_init(sym_t *sym) { - int erred; + bool erred; - erred = 0; + erred = false; if (sym->s_type->t_tspec == FUNC) { /* cannot initialize function: %s */ error(24, sym->s_name); - erred = 1; + erred = true; } else if (sym->s_scl == TYPEDEF) { /* cannot initialize typedef: %s */ error(25, sym->s_name); - erred = 1; + erred = true; } else if (sym->s_scl == EXTERN && sym->s_def == DECL) { /* cannot initialize "extern" declaration: %s */ if (dcs->d_ctx == EXTERN) { @@ -2777,7 +2781,7 @@ check_init(sym_t *sym) } else { /* cannot initialize extern declaration: %s */ error(26, sym->s_name); - erred = 1; + erred = true; } } @@ -2802,11 +2806,11 @@ abstract_name(void) sym->s_blklev = -1; if (dcs->d_ctx == PARG) - sym->s_arg = 1; + sym->s_arg = true; sym->s_type = dcs->d_type; dcs->d_rdcsym = NULL; - dcs->d_vararg = 0; + dcs->d_vararg = false; return sym; } @@ -2878,7 +2882,7 @@ mark_as_set(sym_t *sym) { if (!sym->s_set) { - sym->s_set = 1; + sym->s_set = true; UNIQUE_CURR_POS(sym->s_set_pos); } } @@ -2887,11 +2891,11 @@ mark_as_set(sym_t *sym) * Mark an object as used if it is not already */ void -mark_as_used(sym_t *sym, int fcall, int szof) +mark_as_used(sym_t *sym, bool fcall, bool szof) { if (!sym->s_used) { - sym->s_used = 1; + sym->s_used = true; UNIQUE_CURR_POS(sym->s_use_pos); } /* @@ -2937,7 +2941,7 @@ check_usage(dinfo_t *di) * only set. */ void -check_usage_sym(int novar, sym_t *sym) +check_usage_sym(bool novar, sym_t *sym) { pos_t cpos; @@ -2962,7 +2966,7 @@ check_usage_sym(int novar, sym_t *sym) } static void -check_argument_usage(int novar, sym_t *arg) +check_argument_usage(bool novar, sym_t *arg) { lint_assert(arg->s_set); @@ -2978,7 +2982,7 @@ check_argument_usage(int novar, sym_t *a } static void -check_variable_usage(int novar, sym_t *sym) +check_variable_usage(bool novar, sym_t *sym) { scl_t sc; sym_t *xsym; @@ -3033,11 +3037,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; + xsym->s_used = true; xsym->s_use_pos = sym->s_use_pos; } if (sym->s_set && !xsym->s_set) { - xsym->s_set = 1; + xsym->s_set = true; xsym->s_set_pos = sym->s_set_pos; } } Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.36 src/usr.bin/xlint/lint1/emit1.c:1.37 --- src/usr.bin/xlint/lint1/emit1.c:1.36 Mon Jan 11 19:29:49 2021 +++ src/usr.bin/xlint/lint1/emit1.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.36 2021/01/11 19:29:49 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.37 2021/01/16 02:40: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: emit1.c,v 1.36 2021/01/11 19:29:49 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.37 2021/01/16 02:40:02 rillig Exp $"); #endif #include <ctype.h> @@ -285,7 +285,7 @@ outsym(const sym_t *sym, scl_t sc, def_t outname(sym->s_name); /* renamed name of symbol, if necessary */ - if (sym->s_rename) { + if (sym->s_rename != NULL) { outchar('r'); outname(sym->s_rename); } @@ -301,7 +301,7 @@ outsym(const sym_t *sym, scl_t sc, def_t * they are called with proper argument types */ void -outfdef(const sym_t *fsym, const pos_t *posp, int rval, int osdef, +outfdef(const sym_t *fsym, const pos_t *posp, bool rval, bool osdef, const sym_t *args) { int narg; @@ -378,7 +378,7 @@ outfdef(const sym_t *fsym, const pos_t * outname(fsym->s_name); /* renamed name of function, if necessary */ - if (fsym->s_rename) { + if (fsym->s_rename != NULL) { outchar('r'); outname(fsym->s_rename); } @@ -407,7 +407,7 @@ outfdef(const sym_t *fsym, const pos_t * * (casted to void) */ void -outcall(const tnode_t *tn, int rvused, int rvdisc) +outcall(const tnode_t *tn, bool rvused, bool rvdisc) { tnode_t *args, *arg; int narg, n, i; @@ -496,7 +496,8 @@ outcall(const tnode_t *tn, int rvused, i static void outfstrg(strg_t *strg) { - int c, oc, first; + int c, oc; + bool first; u_char *cp; lint_assert(strg->st_tspec == CHAR); @@ -525,7 +526,7 @@ outfstrg(strg_t *strg) } /* numeric field width */ - while (c != '\0' && isdigit(c)) { + while (c != '\0' && ch_isdigit(c)) { outqchar(c); c = *cp++; } @@ -537,7 +538,7 @@ outfstrg(strg_t *strg) outqchar(c); c = *cp++; } else { - while (c != '\0' && isdigit(c)) { + while (c != '\0' && ch_isdigit(c)) { outqchar(c); c = *cp++; } @@ -567,13 +568,13 @@ outfstrg(strg_t *strg) c = *cp++; if (c == ']') c = *cp++; - first = 1; + first = true; while (c != '\0' && c != ']') { if (c == '-') { if (!first && *cp != ']') outqchar(c); } - first = 0; + first = false; c = *cp++; } if (c == ']') { Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.55 src/usr.bin/xlint/lint1/externs1.h:1.56 --- src/usr.bin/xlint/lint1/externs1.h:1.55 Tue Jan 12 20:42:01 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.55 2021/01/12 20:42:01 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.56 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -35,23 +35,23 @@ * main.c */ extern int aflag; -extern int bflag; -extern int cflag; -extern int dflag; -extern int eflag; -extern int Fflag; -extern int gflag; -extern int hflag; -extern int rflag; -extern int sflag; -extern int tflag; -extern int uflag; -extern int vflag; -extern int yflag; -extern int wflag; -extern int zflag; -extern int Sflag; -extern int Pflag; +extern bool bflag; +extern bool cflag; +extern bool dflag; +extern bool eflag; +extern bool Fflag; +extern bool gflag; +extern bool hflag; +extern bool rflag; +extern bool sflag; +extern bool tflag; +extern bool uflag; +extern bool vflag; +extern bool yflag; +extern bool wflag; +extern bool zflag; +extern bool Sflag; +extern bool Pflag; extern void norecover(void); @@ -68,7 +68,7 @@ extern int yyparse(void); /* * scan.l */ -extern int attron; +extern bool attron; extern pos_t curr_pos; extern pos_t csrc_pos; extern symt_t symtyp; @@ -141,8 +141,8 @@ extern void initdecl(void); extern type_t *gettyp(tspec_t); extern type_t *duptyp(const type_t *); extern type_t *tduptyp(const type_t *); -extern int incompl(const type_t *); -extern void setcomplete(type_t *, int); +extern bool incompl(const type_t *); +extern void setcomplete(type_t *, bool); extern void add_storage_class(scl_t); extern void add_type(type_t *); extern void add_qualifier(tqual_t); @@ -161,35 +161,35 @@ extern sym_t *declarator_1_struct_union( extern sym_t *bitfield(sym_t *, int); extern pqinf_t *merge_pointers_and_qualifiers(pqinf_t *, pqinf_t *); extern sym_t *add_pointer(sym_t *, pqinf_t *); -extern sym_t *add_array(sym_t *, int, int); +extern sym_t *add_array(sym_t *, bool, int); extern sym_t *add_function(sym_t *, sym_t *); -extern void check_function_definition(sym_t *, int); +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, int, int); +extern type_t *mktag(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 *); -extern sym_t *enumeration_constant(sym_t *, int, int); -extern void decl1ext(sym_t *, int); +extern sym_t *enumeration_constant(sym_t *, int, bool); +extern void decl1ext(sym_t *, bool); extern void copy_usage_info(sym_t *, sym_t *); -extern int check_redeclaration(sym_t *, int *); -extern bool eqptrtype(const type_t *, const type_t *, int); -extern int eqtype(const type_t *, const type_t *, int, int, int *); +extern bool check_redeclaration(sym_t *, bool *); +extern bool eqptrtype(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 *, int); +extern sym_t *declare_argument(sym_t *, bool); extern void check_func_lint_directives(void); extern void check_func_old_style_arguments(void); -extern void declare_local(sym_t *, int); +extern void declare_local(sym_t *, bool); extern sym_t *abstract_name(void); extern void global_clean_up(void); extern sym_t *declare_1_abstract(sym_t *); extern void check_size(sym_t *); extern void mark_as_set(sym_t *); -extern void mark_as_used(sym_t *, int, int); +extern void mark_as_used(sym_t *, bool, bool); extern void check_usage(dinfo_t *); -extern void check_usage_sym(int, sym_t *); +extern void check_usage_sym(bool, sym_t *); extern void check_global_symbols(void); extern void print_previous_declaration(int, const sym_t *); @@ -206,7 +206,7 @@ extern tnode_t *build(op_t, tnode_t *, t extern tnode_t *cconv(tnode_t *); extern bool is_strict_bool(const tnode_t *); extern bool typeok(op_t, int, const tnode_t *, const tnode_t *); -extern tnode_t *promote(op_t, int, tnode_t *); +extern tnode_t *promote(op_t, bool, tnode_t *); extern tnode_t *convert(op_t, int, type_t *, tnode_t *); extern void convert_constant(op_t, int, type_t *, val_t *, val_t *); extern tnode_t *build_sizeof(type_t *); @@ -215,9 +215,10 @@ extern tnode_t *build_alignof(type_t *); extern tnode_t *cast(tnode_t *, type_t *); extern tnode_t *new_function_argument_node(tnode_t *, tnode_t *); extern tnode_t *new_function_call_node(tnode_t *, tnode_t *); -extern val_t *constant(tnode_t *, int); -extern void expr(tnode_t *, int, int, int); -extern void check_expr_misc(const tnode_t *, int, int, int, int, int, int); +extern val_t *constant(tnode_t *, bool); +extern void expr(tnode_t *, bool, bool, bool); +extern void check_expr_misc(const tnode_t *, bool, bool, bool, + bool, bool, bool); extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *); extern strg_t *cat_strings(strg_t *, strg_t *); extern int64_t tsize(type_t *); @@ -226,9 +227,9 @@ extern int64_t tsize(type_t *); * func.c */ extern sym_t *funcsym; -extern int reached; -extern int rchflg; -extern int ftflg; +extern bool reached; +extern bool rchflg; +extern bool ftflg; extern int nargusg; extern pos_t argsused_pos; extern int nvararg; @@ -237,12 +238,12 @@ extern int printflike_argnum; extern pos_t printflike_pos; extern int scanflike_argnum; extern pos_t scanflike_pos; -extern int constcond_flag; -extern int llibflg; +extern bool constcond_flag; +extern bool llibflg; extern int lwarn; extern bool bitfieldtype_ok; -extern int plibflg; -extern int quadflg; +extern bool plibflg; +extern bool quadflg; extern void pushctrl(int); extern void popctrl(int); @@ -254,7 +255,7 @@ extern void case_label(tnode_t *); extern void default_label(void); extern void if1(tnode_t *); extern void if2(void); -extern void if3(int); +extern void if3(bool); extern void switch1(tnode_t *); extern void switch2(void); extern void while1(tnode_t *); @@ -267,7 +268,7 @@ extern void dogoto(sym_t *); extern void docont(void); extern void dobreak(void); extern void doreturn(tnode_t *); -extern void global_clean_up_decl(int); +extern void global_clean_up_decl(bool); extern void argsused(int); extern void constcond(int); extern void fallthru(int); @@ -284,7 +285,7 @@ extern void bitfieldtype(int); /* * init.c */ -extern int initerr; +extern bool initerr; extern sym_t *initsym; extern int startinit; @@ -300,8 +301,9 @@ extern void push_member(sbuf_t *); extern void outtype(const type_t *); extern const char *ttos(const type_t *); extern void outsym(const sym_t *, scl_t, def_t); -extern void outfdef(const sym_t *, const pos_t *, int, int, const sym_t *); -extern void outcall(const tnode_t *, int, int); +extern void outfdef(const sym_t *, const pos_t *, bool, bool, + const sym_t *); +extern void outcall(const tnode_t *, bool, bool); extern void outusg(const sym_t *); /* Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.58 src/usr.bin/xlint/lint1/func.c:1.59 --- src/usr.bin/xlint/lint1/func.c:1.58 Fri Jan 15 23:43:51 2021 +++ src/usr.bin/xlint/lint1/func.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.58 2021/01/15 23:43:51 rillig Exp $ */ +/* $NetBSD: func.c,v 1.59 2021/01/16 02:40:02 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.58 2021/01/15 23:43:51 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.59 2021/01/16 02:40:02 rillig Exp $"); #endif #include <stdlib.h> @@ -53,13 +53,13 @@ __RCSID("$NetBSD: func.c,v 1.58 2021/01/ sym_t *funcsym; /* Is set as long as a statement can be reached. Must be set at level 0. */ -int reached = 1; +bool reached = true; /* * Is set as long as NOTREACHED is in effect. * Is reset everywhere where reached can become 0. */ -int rchflg; +bool rchflg; /* * In conjunction with reached, controls printing of "fallthrough on ..." @@ -73,7 +73,7 @@ int rchflg; * evaluated before the following token, which causes reduction of above. * This means that ** FALLTHROUGH ** after "if ..." would always be ignored. */ -int ftflg; +bool ftflg; /* The innermost control statement */ cstk_t *cstmt; @@ -113,20 +113,20 @@ pos_t scanflike_pos; * If both plibflg and llibflg are set, prototypes are written as function * definitions to the output file. */ -int plibflg; +bool plibflg; /* - * Nonzero means that no warnings about constants in conditional + * True means that no warnings about constants in conditional * context are printed. */ -int constcond_flag; +bool constcond_flag; /* * llibflg is set if a lint library shall be created. The effect of * llibflg is that all defined symbols are treated as used. * (The LINTLIBRARY comment also resets vflag.) */ -int llibflg; +bool llibflg; /* * Nonzero if warnings are suppressed by a LINTED directive @@ -144,10 +144,10 @@ int lwarn = LWARN_ALL; bool bitfieldtype_ok; /* - * Nonzero if complaints about use of "long long" are suppressed in + * Whether complaints about use of "long long" are suppressed in * the next statement or declaration. */ -int quadflg; +bool quadflg; /* * Puts a new element at the top of the stack used for control statements. @@ -197,7 +197,7 @@ check_statement_reachable(void) if (!reached && !rchflg) { /* statement not reached */ warning(193); - reached = 1; + reached = true; } } @@ -214,7 +214,8 @@ check_statement_reachable(void) void funcdef(sym_t *fsym) { - int n, dowarn; + int n; + bool dowarn; sym_t *arg, *sym, *rdsym; funcsym = fsym; @@ -236,7 +237,7 @@ funcdef(sym_t *fsym) * if there are no arguments inside the argument list ("f()"). */ if (!fsym->s_type->t_proto && fsym->s_args == NULL) - fsym->s_osdef = 1; + fsym->s_osdef = true; check_type(fsym); @@ -259,7 +260,7 @@ funcdef(sym_t *fsym) } if (dcs->d_inline) - fsym->s_inline = 1; + fsym->s_inline = true; /* * Arguments in new style function declarations need a name. @@ -286,7 +287,7 @@ funcdef(sym_t *fsym) if ((rdsym = dcs->d_rdcsym) != NULL) { - if (!check_redeclaration(fsym, (dowarn = 0, &dowarn))) { + if (!check_redeclaration(fsym, (dowarn = false, &dowarn))) { /* * Print nothing if the newly defined function @@ -319,7 +320,7 @@ funcdef(sym_t *fsym) /* once a function is inline it remains inline */ if (rdsym->s_inline) - fsym->s_inline = 1; + fsym->s_inline = true; } @@ -336,9 +337,9 @@ funcdef(sym_t *fsym) if (dcs->d_notyp) /* return value is implicitly declared to be int */ - fsym->s_rimpl = 1; + fsym->s_rimpl = true; - reached = 1; + reached = true; } /* @@ -351,7 +352,7 @@ funcend(void) int n; if (reached) { - cstmt->c_noretval = 1; + cstmt->c_noretval = true; if (funcsym->s_type->t_subt->t_tspec != VOID && !funcsym->s_rimpl) { /* func. %s falls off bottom without returning value */ @@ -400,7 +401,7 @@ funcend(void) rmsyms(dcs->d_fpsyms); /* must be set on level 0 */ - reached = 1; + reached = true; } void @@ -414,7 +415,7 @@ named_label(sym_t *sym) mark_as_set(sym); } - reached = 1; + reached = true; } static void @@ -504,7 +505,7 @@ case_label(tnode_t *tn) tfreeblk(); - reached = 1; + reached = true; } void @@ -528,10 +529,10 @@ default_label(void) /* fallthrough on default statement */ warning(284); } - ci->c_default = 1; + ci->c_default = true; } - reached = 1; + reached = true; } static tnode_t * @@ -583,8 +584,8 @@ void if2(void) { - cstmt->c_rchif = reached ? 1 : 0; - reached = 1; + cstmt->c_rchif = reached; + reached = true; } /* @@ -592,13 +593,13 @@ if2(void) * if_without_else T_ELSE statement */ void -if3(int els) +if3(bool els) { if (els) { reached |= cstmt->c_rchif; } else { - reached = 1; + reached = true; } popctrl(T_IF); } @@ -647,11 +648,11 @@ switch1(tnode_t *tn) expr(tn, 1, 0, 1); pushctrl(T_SWITCH); - cstmt->c_switch = 1; + cstmt->c_switch = true; cstmt->c_swtype = tp; - reached = rchflg = 0; - ftflg = 1; + reached = rchflg = false; + ftflg = true; } /* @@ -691,14 +692,14 @@ switch2(void) * end of switch alway reached (c_break is only set if the * break statement can be reached). */ - reached = 1; + reached = true; } else if (!cstmt->c_default && (!hflag || !cstmt->c_swtype->t_isenum || nenum != nclab)) { /* * there are possible values which are not handled in * switch */ - reached = 1; + reached = true; } /* * otherwise the end of the switch expression is reached * if the end of the last statement inside it is reached. @@ -717,14 +718,14 @@ while1(tnode_t *tn) if (!reached) { /* loop not entered at top */ warning(207); - reached = 1; + reached = true; } if (tn != NULL) tn = check_controlling_expression(tn); pushctrl(T_WHILE); - cstmt->c_loop = 1; + cstmt->c_loop = true; if (tn != NULL && tn->tn_op == CON) cstmt->c_infinite = is_nonzero(tn); @@ -744,7 +745,7 @@ while2(void) * or there was a break statement which was reached. */ reached = !cstmt->c_infinite || cstmt->c_break; - rchflg = 0; + rchflg = false; popctrl(T_WHILE); } @@ -759,11 +760,11 @@ do1(void) if (!reached) { /* loop not entered at top */ warning(207); - reached = 1; + reached = true; } pushctrl(T_DO); - cstmt->c_loop = 1; + cstmt->c_loop = true; } /* @@ -779,7 +780,7 @@ do2(tnode_t *tn) * loop is reached. */ if (cstmt->c_cont) - reached = 1; + reached = true; if (tn != NULL) tn = check_controlling_expression(tn); @@ -798,7 +799,7 @@ do2(tnode_t *tn) * or there was a break statement which could be reached. */ reached = !cstmt->c_infinite || cstmt->c_break; - rchflg = 0; + rchflg = false; popctrl(T_DO); } @@ -817,11 +818,11 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t if (tn1 != NULL && !reached) { /* loop not entered at top */ warning(207); - reached = 1; + reached = true; } pushctrl(T_FOR); - cstmt->c_loop = 1; + cstmt->c_loop = true; /* * Store the tree memory for the reinitialisation expression. @@ -846,7 +847,7 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t /* Checking the reinitialisation expression is done in for2() */ - reached = 1; + reached = true; } /* @@ -860,7 +861,7 @@ for2(void) tnode_t *tn3; if (cstmt->c_cont) - reached = 1; + reached = true; cpos = curr_pos; cspos = csrc_pos; @@ -875,7 +876,7 @@ for2(void) if (!reached && !rchflg) { /* end-of-loop code not reached */ warning(223); - reached = 1; + reached = true; } if (tn3 != NULL) { @@ -889,7 +890,7 @@ for2(void) /* An endless loop without break will never terminate */ reached = cstmt->c_break || !cstmt->c_infinite; - rchflg = 0; + rchflg = false; popctrl(T_FOR); } @@ -906,7 +907,7 @@ dogoto(sym_t *lab) check_statement_reachable(); - reached = rchflg = 0; + reached = rchflg = false; } /* @@ -926,13 +927,13 @@ dobreak(void) error(208); } else { if (reached) - ci->c_break = 1; + ci->c_break = true; } if (bflag) check_statement_reachable(); - reached = rchflg = 0; + reached = rchflg = false; } /* @@ -950,12 +951,12 @@ docont(void) /* continue outside loop */ error(209); } else { - ci->c_cont = 1; + ci->c_cont = true; } check_statement_reachable(); - reached = rchflg = 0; + reached = rchflg = false; } /* @@ -973,9 +974,9 @@ doreturn(tnode_t *tn) continue; if (tn != NULL) { - ci->c_retval = 1; + ci->c_retval = true; } else { - ci->c_noretval = 1; + ci->c_noretval = true; } if (tn != NULL && funcsym->s_type->t_subt->t_tspec == VOID) { @@ -999,8 +1000,8 @@ doreturn(tnode_t *tn) ln = tgetblk(sizeof (tnode_t)); ln->tn_op = NAME; ln->tn_type = tduptyp(funcsym->s_type->t_subt); - ln->tn_type->t_const = 0; - ln->tn_lvalue = 1; + ln->tn_type->t_const = false; + ln->tn_lvalue = true; ln->tn_sym = funcsym; /* better than nothing */ tn = build(RETURN, ln, tn); @@ -1024,7 +1025,7 @@ doreturn(tnode_t *tn) } - reached = rchflg = 0; + reached = rchflg = false; } /* @@ -1032,7 +1033,7 @@ doreturn(tnode_t *tn) * Especially remove information about unused lint comments. */ void -global_clean_up_decl(int silent) +global_clean_up_decl(bool silent) { pos_t cpos; @@ -1073,7 +1074,7 @@ global_clean_up_decl(int silent) curr_pos = cpos; - dcs->d_asm = 0; + dcs->d_asm = false; } /* @@ -1189,7 +1190,7 @@ void constcond(int n) { - constcond_flag = 1; + constcond_flag = true; } /* @@ -1201,7 +1202,7 @@ void fallthru(int n) { - ftflg = 1; + ftflg = true; } /* @@ -1213,8 +1214,8 @@ void notreach(int n) { - reached = 0; - rchflg = 1; + reached = false; + rchflg = true; } /* ARGSUSED */ @@ -1227,8 +1228,8 @@ lintlib(int n) warning(280, "LINTLIBRARY"); return; } - llibflg = 1; - vflag = 0; + llibflg = true; + vflag = false; } /* @@ -1274,17 +1275,14 @@ protolib(int n) warning(280, "PROTOLIB"); return; } - plibflg = n == 0 ? 0 : 1; + plibflg = n != 0; } -/* - * Set quadflg to nonzero which means that the next statement/declaration - * may use "long long" without an error or warning. - */ +/* The next statement/declaration may use "long long" without a diagnostic. */ /* ARGSUSED */ void longlong(int n) { - quadflg = 1; + quadflg = true; } Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.61 src/usr.bin/xlint/lint1/init.c:1.62 --- src/usr.bin/xlint/lint1/init.c:1.61 Sun Jan 10 00:05:46 2021 +++ src/usr.bin/xlint/lint1/init.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.61 2021/01/10 00:05:46 rillig Exp $ */ +/* $NetBSD: init.c,v 1.62 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: init.c,v 1.61 2021/01/10 00:05:46 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.62 2021/01/16 02:40:02 rillig Exp $"); #endif #include <stdlib.h> @@ -98,7 +98,7 @@ typedef struct namlist { * The effect is that the rest of the initialisation is ignored (parsed * by yacc, expression trees built, but no initialisation takes place). */ -int initerr; +bool initerr; /* Pointer to the symbol which is to be initialized. */ sym_t *initsym; @@ -110,7 +110,7 @@ istk_t *initstk; namlist_t *namedmem = NULL; -static int initstack_string(tnode_t *); +static bool initstack_string(tnode_t *); #ifndef DEBUG #define DPRINTF(a) @@ -252,7 +252,7 @@ initstack_pop_item(void) error(101, namedmem->n_name); DPRINTF(("%s: end rhs.name=%s\n", __func__, namedmem->n_name)); pop_member(); - istk->i_namedmem = 1; + istk->i_namedmem = true; return; } /* @@ -277,7 +277,7 @@ initstack_pop_item(void) static void initstack_pop_brace(void) { - int brace; + bool brace; DPRINTF(("%s\n", __func__)); do { @@ -340,12 +340,12 @@ again: DPRINTF(("%s(%s)\n", __func__, type_name(istk->i_type))); switch (istk->i_type->t_tspec) { case ARRAY: - if (namedmem) { + if (namedmem != NULL) { DPRINTF(("%s: ARRAY %s brace=%d\n", __func__, namedmem->n_name, istk->i_brace)); goto pop; } else if (istk->i_next->i_namedmem) { - istk->i_brace = 1; + istk->i_brace = true; DPRINTF(("%s ARRAY brace=%d, namedmem=%d\n", __func__, istk->i_brace, istk->i_next->i_namedmem)); } @@ -353,7 +353,7 @@ again: if (incompl(istk->i_type) && istk->i_next->i_next != NULL) { /* initialisation of an incomplete type */ error(175); - initerr = 1; + initerr = true; return; } istk->i_subt = istk->i_type->t_subt; @@ -372,7 +372,7 @@ again: if (incompl(istk->i_type)) { /* initialisation of an incomplete type */ error(175); - initerr = 1; + initerr = true; return; } cnt = 0; @@ -403,26 +403,26 @@ again: } istk->i_mem = m; istk->i_subt = m->s_type; - istk->i_namedmem = 1; + istk->i_namedmem = true; DPRINTF(("%s: named name=%s\n", __func__, namedmem->n_name)); pop_member(); cnt = istk->i_type->t_tspec == STRUCT ? 2 : 1; } - istk->i_brace = 1; + istk->i_brace = true; DPRINTF(("%s: unnamed type=%s, brace=%d\n", __func__, type_name(istk->i_type ? istk->i_type : istk->i_subt), istk->i_brace)); if (cnt == 0) { /* cannot init. struct/union with no named member */ error(179); - initerr = 1; + initerr = true; return; } istk->i_remaining = istk->i_type->t_tspec == STRUCT ? cnt : 1; break; default: - if (namedmem) { + if (namedmem != NULL) { DPRINTF(("%s: pop\n", __func__)); pop: inxt = initstk->i_next; @@ -462,7 +462,7 @@ initstack_check_too_many(void) error(174); break; } - initerr = 1; + initerr = true; } } @@ -474,14 +474,14 @@ initstack_next_brace(void) if (initstk->i_type != NULL && is_scalar(initstk->i_type->t_tspec)) { /* invalid initializer type %s */ error(176, type_name(initstk->i_type)); - initerr = 1; + initerr = true; } if (!initerr) initstack_check_too_many(); if (!initerr) initstack_push(); if (!initerr) { - initstk->i_brace = 1; + initstk->i_brace = true; DPRINTF(("%s: %p %s\n", __func__, namedmem, type_name( initstk->i_type ? initstk->i_type : initstk->i_subt))); } @@ -581,7 +581,7 @@ mkinit(tnode_t *tn) initsym->s_type->t_tspec != ARRAY && initstk->i_next == NULL) { ln = new_name_node(initsym, 0); ln->tn_type = tduptyp(ln->tn_type); - ln->tn_type->t_const = 0; + ln->tn_type->t_const = false; tn = build(ASSIGN, ln, tn); expr(tn, 0, 0, 0); return; @@ -608,8 +608,8 @@ mkinit(tnode_t *tn) ln = tgetblk(sizeof (tnode_t)); ln->tn_op = NAME; ln->tn_type = tduptyp(initstk->i_type); - ln->tn_type->t_const = 0; - ln->tn_lvalue = 1; + ln->tn_type->t_const = false; + ln->tn_lvalue = true; ln->tn_sym = initsym; /* better than nothing */ tn = cconv(tn); @@ -659,7 +659,7 @@ mkinit(tnode_t *tn) } -static int +static bool initstack_string(tnode_t *tn) { tspec_t t; @@ -710,7 +710,7 @@ initstack_string(tnode_t *tn) len = strg->st_len; if (istk->i_nolimit) { - istk->i_nolimit = 0; + istk->i_nolimit = false; istk->i_type->t_dim = len + 1; setcomplete(istk->i_type, 1); } else { Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.54 src/usr.bin/xlint/lint1/lint1.h:1.55 --- src/usr.bin/xlint/lint1/lint1.h:1.54 Fri Jan 15 23:43:51 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.54 2021/01/15 23:43:51 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.55 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -104,7 +104,7 @@ typedef enum { */ typedef struct { tspec_t v_tspec; - int v_ansiu; /* set if an integer constant is + bool v_ansiu; /* set if an integer constant is unsigned in ANSI C */ union { int64_t _v_quad; /* integers */ @@ -418,7 +418,7 @@ typedef struct err_set { #define ERR_CLR(n, p) \ ((p)->errs_bits[(n)/__NERRBITS] &= ~(1 << ((n) % __NERRBITS))) #define ERR_ISSET(n, p) \ - ((p)->errs_bits[(n)/__NERRBITS] & (1 << ((n) % __NERRBITS))) + (((p)->errs_bits[(n)/__NERRBITS] & (1 << ((n) % __NERRBITS))) != 0) #define ERR_ZERO(p) (void)memset((p), 0, sizeof(*(p))) #define LERROR(fmt, args...) lerror(__FILE__, __LINE__, fmt, ##args) Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.35 src/usr.bin/xlint/lint1/main1.c:1.36 --- src/usr.bin/xlint/lint1/main1.c:1.35 Tue Jan 12 21:48:10 2021 +++ src/usr.bin/xlint/lint1/main1.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.35 2021/01/12 21:48:10 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.36 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.35 2021/01/12 21:48:10 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.36 2021/01/16 02:40:02 rillig Exp $"); #endif #include <sys/types.h> @@ -52,7 +52,7 @@ __RCSID("$NetBSD: main1.c,v 1.35 2021/01 #include "lint1.h" /* set yydebug to 1*/ -int yflag; +bool yflag; /* * Print warnings if an assignment of an integer type to another integer type @@ -63,66 +63,66 @@ int yflag; int aflag; /* Print a warning if a break statement cannot be reached. */ -int bflag; +bool bflag; /* Print warnings for pointer casts. */ -int cflag; +bool cflag; /* Print various debug information. */ -int dflag; +bool dflag; /* Perform stricter checking of enum types and operations on enum types. */ -int eflag; +bool eflag; /* Print complete pathnames, not only the basename. */ -int Fflag; +bool Fflag; /* Enable some extensions of gcc */ -int gflag; +bool gflag; /* Treat warnings as errors */ -int wflag; +bool wflag; /* * Apply a number of heuristic tests to attempt to intuit bugs, improve * style, and reduce waste. */ -int hflag; +bool hflag; /* Attempt to check portability to other dialects of C. */ -int pflag; +bool pflag; /* * In case of redeclarations/redefinitions print the location of the * previous declaration/definition. */ -int rflag; +bool rflag; /* Strict ANSI C mode. */ -int sflag; +bool sflag; bool Tflag; /* Traditional C mode. */ -int tflag; +bool tflag; /* Enable C9X extensions */ -int Sflag; +bool Sflag; /* Picky flag */ -int Pflag; +bool Pflag; /* * Complain about functions and external variables used and not defined, * or defined and not used. */ -int uflag = 1; +bool uflag = true; /* Complain about unused function arguments. */ -int vflag = 1; +bool vflag = true; /* Complain about structures which are never defined. */ -int zflag = 1; +bool zflag = true; err_set msgset; @@ -166,7 +166,7 @@ bltin(void) static void sigfpe(int s) { - fpe = 1; + fpe = true; } int @@ -181,25 +181,25 @@ main(int argc, char *argv[]) while ((c = getopt(argc, argv, "abcdeghmprstuvwyzFPR:STX:")) != -1) { switch (c) { case 'a': aflag++; break; - case 'b': bflag = 1; break; - case 'c': cflag = 1; break; - case 'd': dflag = 1; break; - case 'e': eflag = 1; break; - case 'F': Fflag = 1; break; - case 'g': gflag = 1; break; - case 'h': hflag = 1; break; - case 'p': pflag = 1; break; - case 'P': Pflag = 1; break; - case 'r': rflag = 1; break; - case 's': sflag = 1; break; - case 'S': Sflag = 1; break; + case 'b': bflag = true; break; + case 'c': cflag = true; break; + case 'd': dflag = true; break; + case 'e': eflag = true; break; + case 'F': Fflag = true; break; + case 'g': gflag = true; break; + case 'h': hflag = true; break; + case 'p': pflag = true; break; + case 'P': Pflag = true; break; + case 'r': rflag = true; break; + case 's': sflag = true; break; + case 'S': Sflag = true; break; case 'T': Tflag = true; break; - case 't': tflag = 1; break; - case 'u': uflag = 0; break; - case 'w': wflag = 1; break; - case 'v': vflag = 0; break; - case 'y': yflag = 1; break; - case 'z': zflag = 0; break; + case 't': tflag = true; break; + case 'u': uflag = false; break; + case 'w': wflag = true; break; + case 'v': vflag = false; break; + case 'y': yflag = true; break; + case 'z': zflag = false; break; case 'm': msglist(); @@ -210,7 +210,7 @@ main(int argc, char *argv[]) break; case 'X': - for (ptr = strtok(optarg, ","); ptr; + for (ptr = strtok(optarg, ","); ptr != NULL; ptr = strtok(NULL, ",")) { char *eptr; long msg; @@ -221,7 +221,7 @@ main(int argc, char *argv[]) errno == ERANGE) err(1, "invalid error message id '%s'", ptr); - if (*eptr || ptr == eptr || msg < 0 || + if (*eptr != '\0' || ptr == eptr || msg < 0 || msg >= ERR_SETSIZE) errx(1, "invalid error message id '%s'", ptr); @@ -276,7 +276,7 @@ main(int argc, char *argv[]) outclose(); - return nerr != 0; + return nerr != 0 ? 1 : 0; } static void Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.22 src/usr.bin/xlint/lint1/mem1.c:1.23 --- src/usr.bin/xlint/lint1/mem1.c:1.22 Mon Jan 4 22:29:00 2021 +++ src/usr.bin/xlint/lint1/mem1.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.22 2021/01/04 22:29:00 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.23 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.22 2021/01/04 22:29:00 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.23 2021/01/16 02:40:02 rillig Exp $"); #endif #include <sys/types.h> @@ -119,7 +119,7 @@ fnxform(const char *name, size_t len) static char buf[MAXPATHLEN]; struct repl *r; - for (r = replist; r; r = r->next) + for (r = replist; r != NULL; r = r->next) if (r->len < len && memcmp(name, r->orig, r->len) == 0) break; if (r == NULL) @@ -247,7 +247,7 @@ xgetblk(mbl_t **mbp, size_t s) #ifndef BLKDEBUG (void)memset(mb->blk, 0, mb->size); #endif - if (t) + if (t > 0) mblklen = t; } else { frmblks = mb->nxt; Index: src/usr.bin/xlint/lint1/oper.c diff -u src/usr.bin/xlint/lint1/oper.c:1.3 src/usr.bin/xlint/lint1/oper.c:1.4 --- src/usr.bin/xlint/lint1/oper.c:1.3 Tue Jan 12 20:42:01 2021 +++ src/usr.bin/xlint/lint1/oper.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: oper.c,v 1.3 2021/01/12 20:42:01 rillig Exp $ */ +/* $NetBSD: oper.c,v 1.4 2021/01/16 02:40:02 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ mod_t modtab[NOPS]; static const struct { mod_t m; - unsigned char ok; + bool ok; } imods[] = #define begin_ops() { #define op(name, repr, \ Index: src/usr.bin/xlint/lint1/scan.l diff -u src/usr.bin/xlint/lint1/scan.l:1.117 src/usr.bin/xlint/lint1/scan.l:1.118 --- src/usr.bin/xlint/lint1/scan.l:1.117 Thu Jan 14 07:34:48 2021 +++ src/usr.bin/xlint/lint1/scan.l Sat Jan 16 02:40:02 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.117 2021/01/14 07:34:48 rillig Exp $ */ +/* $NetBSD: scan.l,v 1.118 2021/01/16 02:40:02 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: scan.l,v 1.117 2021/01/14 07:34:48 rillig Exp $"); +__RCSID("$NetBSD: scan.l,v 1.118 2021/01/16 02:40:02 rillig Exp $"); #endif #include <ctype.h> @@ -61,7 +61,7 @@ pos_t curr_pos = { 1, "", 0 }; pos_t csrc_pos = { 1, "", 0 }; /* Are we parsing a gcc attribute? */ -int attron; +bool attron; static void incline(void); static void badchar(int); @@ -570,7 +570,7 @@ icon(int base) const char *cp; char c, *eptr; tspec_t typ; - int ansiu; + bool ansiu; #ifdef TARG_INT128_MAX __uint128_t uq = 0; static tspec_t contypes[2][4] = { @@ -632,7 +632,7 @@ icon(int base) * If the value is too big for the current type, we must choose * another type. */ - ansiu = 0; + ansiu = false; switch (typ) { case INT: if (uq <= TARG_INT_MAX) { @@ -656,7 +656,7 @@ icon(int base) * Remember that the constant is unsigned * only in ANSI C */ - ansiu = 1; + ansiu = true; } } break; @@ -673,7 +673,7 @@ icon(int base) if (uq > TARG_LONG_MAX && !tflag) { typ = ULONG; if (!sflag) - ansiu = 1; + ansiu = true; if (uq > TARG_ULONG_MAX) { /* integer constant out of range */ warning(252); @@ -690,7 +690,7 @@ icon(int base) if (uq > TARG_QUAD_MAX && !tflag) { typ = UQUAD; if (!sflag) - ansiu = 1; + ansiu = true; } break; case UQUAD: @@ -705,7 +705,7 @@ icon(int base) if (uq > TARG_INT128_MAX && !tflag) { typ = UINT128; if (!sflag) - ansiu = 1; + ansiu = true; } #endif break; @@ -1127,15 +1127,14 @@ directive(void) char c, *eptr; size_t fnl; long ln; - static int first = 1; + static bool first = true; /* Go to first non-whitespace after # */ for (cp = yytext + 1; (c = *cp) == ' ' || c == '\t'; cp++) continue; - if (!isdigit((unsigned char)c)) { - if (strncmp(cp, "pragma", 6) == 0 - && isspace((unsigned char)cp[6])) + if (!ch_isdigit(c)) { + if (strncmp(cp, "pragma", 6) == 0 && ch_isspace(cp[6])) return; error: /* undefined or invalid # directive */ @@ -1181,7 +1180,7 @@ directive(void) csrc_pos.p_file = curr_pos.p_file; outsrc(fnxform(curr_pos.p_file, strlen(curr_pos.p_file))); - first = 0; + first = false; } } curr_pos.p_line = (int)ln - 1; @@ -1239,9 +1238,9 @@ comment(void) char arg[32]; size_t l, i; int a; - int eoc; + bool eoc; - eoc = 0; + eoc = false; /* Skip white spaces after the start of the comment */ while ((c = inpc()) != EOF && isspace(c)) @@ -1291,7 +1290,7 @@ comment(void) * remember that we have already found the end of the * comment */ - eoc = 1; + eoc = true; } if (keywtab[i].func != NULL) @@ -1306,7 +1305,7 @@ comment(void) break; } if (lc == '*' && c == '/') - eoc = 1; + eoc = true; } } @@ -1338,8 +1337,8 @@ clrwflgs(void) { lwarn = LWARN_ALL; - quadflg = 0; - constcond_flag = 0; + quadflg = false; + constcond_flag = false; } /* @@ -1535,8 +1534,8 @@ mktempsym(type_t *t) sym->s_blklev = blklev; sym->s_scl = AUTO; sym->s_kind = FVFT; - sym->s_used = 1; - sym->s_set = 1; + sym->s_used = true; + sym->s_set = true; if ((sym->s_link = symtab[h]) != NULL) symtab[h]->s_rlink = &sym->s_link; Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.153 src/usr.bin/xlint/lint1/tree.c:1.154 --- src/usr.bin/xlint/lint1/tree.c:1.153 Fri Jan 15 23:43:51 2021 +++ src/usr.bin/xlint/lint1/tree.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.153 2021/01/15 23:43:51 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.154 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.153 2021/01/15 23:43:51 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.154 2021/01/16 02:40:02 rillig Exp $"); #endif #include <float.h> @@ -53,7 +53,7 @@ __RCSID("$NetBSD: tree.c,v 1.153 2021/01 static tnode_t *new_integer_constant_node(tspec_t, int64_t); static void check_pointer_comparison(op_t, const tnode_t *, const tnode_t *); -static int check_assign_types_compatible(op_t, int, +static bool check_assign_types_compatible(op_t, int, const tnode_t *, const tnode_t *); static void check_bad_enum_operation(op_t, const tnode_t *, const tnode_t *); @@ -78,7 +78,7 @@ static void check_pointer_conversion(op_ static tnode_t *build_struct_access(op_t, tnode_t *, tnode_t *); static tnode_t *build_prepost_incdec(op_t, tnode_t *); static tnode_t *build_real_imag(op_t, tnode_t *); -static tnode_t *build_ampersand(tnode_t *, int); +static tnode_t *build_ampersand(tnode_t *, bool); static tnode_t *build_plus_minus(op_t, tnode_t *, tnode_t *); static tnode_t *build_bit_shift(op_t, tnode_t *, tnode_t *); static tnode_t *build_colon(tnode_t *, tnode_t *); @@ -91,7 +91,7 @@ static tnode_t *check_function_arguments static tnode_t *check_prototype_argument(int, type_t *, tnode_t *); static void check_null_effect(const tnode_t *); static void display_expression(const tnode_t *, int); -static void check_array_index(tnode_t *, int); +static void check_array_index(tnode_t *, bool); static void check_integer_comparison(op_t, tnode_t *, tnode_t *); static void check_precedence_confusion(tnode_t *); @@ -227,30 +227,30 @@ new_name_node(sym_t *sym, int ntok) */ sym->s_type = incref(sym->s_type, FUNC); } else { - if (!blklev) { + if (blklev == 0) { /* %s undefined */ error(99, sym->s_name); } else { - int fixtype; + bool fixtype; if (strcmp(sym->s_name, "__FUNCTION__") == 0 || strcmp(sym->s_name, "__PRETTY_FUNCTION__") == 0) { /* __FUNCTION__/__PRETTY_FUNCTION... */ gnuism(316); - fixtype = 1; + fixtype = true; } else if (strcmp(sym->s_name, "__func__") == 0) { if (!Sflag) /* __func__ is a C9X feature */ warning(317); - fixtype = 1; + fixtype = true; } else { /* %s undefined */ error(99, sym->s_name); - fixtype = 0; + fixtype = false; } if (fixtype) { sym->s_type = incref(gettyp(CHAR), PTR); - sym->s_type->t_const = 1; + sym->s_type->t_const = true; } } } @@ -265,7 +265,7 @@ new_name_node(sym_t *sym, int ntok) n->tn_op = NAME; n->tn_sym = sym; if (sym->s_kind == FVFT && sym->s_type->t_tspec != FUNC) - n->tn_lvalue = 1; + n->tn_lvalue = true; } else { n->tn_op = CON; n->tn_val = tgetblk(sizeof (val_t)); @@ -288,7 +288,7 @@ new_string_node(strg_t *strg) n->tn_op = STRING; n->tn_type = tincref(gettyp(strg->st_tspec), ARRAY); n->tn_type->t_dim = len + 1; - n->tn_lvalue = 1; + n->tn_lvalue = true; n->tn_string = tgetblk(sizeof (strg_t)); n->tn_string->st_tspec = strg->st_tspec; @@ -319,7 +319,7 @@ struct_or_union_member(tnode_t *tn, op_t str_t *str; type_t *tp; sym_t *sym, *csym; - int eq; + bool eq; tspec_t t; /* @@ -371,29 +371,30 @@ struct_or_union_member(tnode_t *tn, op_t * Set eq to 0 if there are struct/union members with the same name * and different types and/or offsets. */ - eq = 1; + eq = true; for (csym = msym; csym != NULL; csym = csym->s_link) { if (csym->s_scl != MOS && csym->s_scl != MOU) continue; if (strcmp(msym->s_name, csym->s_name) != 0) continue; for (sym = csym->s_link ; sym != NULL; sym = sym->s_link) { - int w; + bool w; if (sym->s_scl != MOS && sym->s_scl != MOU) continue; if (strcmp(csym->s_name, sym->s_name) != 0) continue; if (csym->s_value.v_quad != sym->s_value.v_quad) { - eq = 0; + eq = false; break; } - w = 0; - eq = eqtype(csym->s_type, sym->s_type, 0, 0, &w) && !w; + w = false; + eq = eqtype(csym->s_type, sym->s_type, + false, false, &w) && !w; if (!eq) break; if (csym->s_bitfield != sym->s_bitfield) { - eq = 0; + eq = false; break; } if (csym->s_bitfield) { @@ -402,11 +403,11 @@ struct_or_union_member(tnode_t *tn, op_t tp1 = csym->s_type; tp2 = sym->s_type; if (tp1->t_flen != tp2->t_flen) { - eq = 0; + eq = false; break; } if (tp1->t_foffs != tp2->t_foffs) { - eq = 0; + eq = false; break; } } @@ -532,12 +533,12 @@ build(op_t op, tnode_t *ln, tnode_t *rn) if (mp->m_tlansiu && ln->tn_op == CON && ln->tn_val->v_ansiu) { /* ANSI C treats constant as unsigned, op %s */ warning(218, mp->m_name); - ln->tn_val->v_ansiu = 0; + ln->tn_val->v_ansiu = false; } if (mp->m_transiu && rn->tn_op == CON && rn->tn_val->v_ansiu) { /* ANSI C treats constant as unsigned, op %s */ warning(218, mp->m_name); - rn->tn_val->v_ansiu = 0; + rn->tn_val->v_ansiu = false; } /* Make sure both operands are of the same type */ @@ -642,7 +643,8 @@ build(op_t op, tnode_t *ln, tnode_t *rn) ntn = fold(ntn); } } else if (op == QUEST && ln->tn_op == CON) { - ntn = ln->tn_val->v_quad ? rn->tn_left : rn->tn_right; + ntn = ln->tn_val->v_quad != 0 + ? rn->tn_left : rn->tn_right; } } @@ -686,7 +688,7 @@ cconv(tnode_t *tn) /* lvalue to rvalue */ if (tn->tn_lvalue) { tp = tduptyp(tn->tn_type); - tp->t_const = tp->t_volatile = 0; + tp->t_const = tp->t_volatile = false; tn = new_tnode(LOAD, tp, tn, NULL); } @@ -1400,10 +1402,10 @@ typeok_enum(op_t op, const mod_t *mp, in (ltp->t_isenum || (mp->m_binary && rtp->t_isenum))) { check_bad_enum_operation(op, ln, rn); } else if (mp->m_valid_on_enum && - (ltp->t_isenum && rtp && rtp->t_isenum)) { + (ltp->t_isenum && rtp != NULL && rtp->t_isenum)) { check_enum_type_mismatch(op, arg, ln, rn); } else if (mp->m_valid_on_enum && - (ltp->t_isenum || (rtp && rtp->t_isenum))) { + (ltp->t_isenum || (rtp != NULL && rtp->t_isenum))) { check_enum_int_mismatch(op, arg, ln, rn); } } @@ -1479,7 +1481,7 @@ check_pointer_comparison(op_t op, const * and prints warnings/errors if necessary. * If the types are (almost) compatible, 1 is returned, otherwise 0. */ -static int +static bool check_assign_types_compatible(op_t op, int arg, const tnode_t *ln, const tnode_t *rn) { @@ -1495,10 +1497,10 @@ check_assign_types_compatible(op_t op, i mp = &modtab[op]; if (lt == BOOL && is_scalar(rt)) /* C99 6.3.1.2 */ - return 1; + return true; if (is_arithmetic(lt) && is_arithmetic(rt)) - return 1; + return true; if ((lt == STRUCT || lt == UNION) && (rt == STRUCT || rt == UNION)) /* both are struct or union */ @@ -1507,7 +1509,7 @@ check_assign_types_compatible(op_t op, i /* 0, 0L and (void *)0 may be assigned to any pointer */ if (lt == PTR && ((rt == PTR && rst == VOID) || is_integer(rt))) { if (rn->tn_op == CON && rn->tn_val->v_quad == 0) - return 1; + return true; } if (lt == PTR && rt == PTR && (lst == VOID || rst == VOID)) { @@ -1559,7 +1561,7 @@ check_assign_types_compatible(op_t op, i break; } } - return 1; + return true; } if ((lt == PTR && is_integer(rt)) || (is_integer(lt) && rt == PTR)) { @@ -1583,7 +1585,7 @@ check_assign_types_compatible(op_t op, i lx, type_name(ltp), rx, type_name(rtp), mp->m_name); break; } - return 1; + return true; } if (lt == PTR && rt == PTR) { @@ -1600,7 +1602,7 @@ check_assign_types_compatible(op_t op, i warn_incompatible_pointers(mp, ltp, rtp); break; } - return 1; + return true; } switch (op) { @@ -1621,7 +1623,7 @@ check_assign_types_compatible(op_t op, i break; } - return 0; + return false; } /* @@ -1798,7 +1800,7 @@ new_tnode(op_t op, type_t *type, tnode_t lint_assert(ln->tn_type->t_tspec == PTR); t = ln->tn_type->t_subt->t_tspec; if (t != FUNC && t != VOID) - ntn->tn_lvalue = 1; + ntn->tn_lvalue = true; break; default: break; @@ -1815,7 +1817,7 @@ new_tnode(op_t op, type_t *type, tnode_t * float to double. */ tnode_t * -promote(op_t op, int farg, tnode_t *tn) +promote(op_t op, bool farg, tnode_t *tn) { tspec_t t; type_t *ntp; @@ -1892,7 +1894,8 @@ static void balance(op_t op, tnode_t **lnp, tnode_t **rnp) { tspec_t lt, rt, t; - int i, u; + int i; + bool u; type_t *ntp; static tspec_t tl[] = { LDOUBLE, DOUBLE, FLOAT, UQUAD, QUAD, ULONG, LONG, UINT, INT, @@ -2089,7 +2092,7 @@ check_integer_conversion(op_t op, int ar if (Pflag && psize(nt) > psize(ot) && is_uinteger(nt) != is_uinteger(ot)) { - if (aflag && pflag) { + if (aflag > 0 && pflag) { if (op == FARG) { /* conversion to '%s' may sign-extend ... */ warning(297, type_name(tp), arg); @@ -2119,7 +2122,7 @@ check_integer_conversion(op_t op, int ar (ot == LONG || ot == ULONG || ot == QUAD || ot == UQUAD || aflag > 1)) { /* conversion from '%s' may lose accuracy */ - if (aflag) { + if (aflag > 0) { if (op == FARG) { /* conv. from '%s' to '%s' may lose ... */ warning(298, @@ -2224,16 +2227,17 @@ convert_constant(op_t op, int arg, type_ { tspec_t ot, nt; ldbl_t max = 0.0, min = 0.0; - int sz, rchk; + int sz; + bool rchk; int64_t xmask, xmsk1; int osz, nsz; ot = v->v_tspec; nt = nv->v_tspec = tp->t_tspec; - rchk = 0; + rchk = false; if (nt == BOOL) { /* C99 6.3.1.2 */ - nv->v_ansiu = 0; + nv->v_ansiu = false; nv->v_quad = is_nonzero_val(ot, v) ? 1 : 0; return; } @@ -2311,7 +2315,7 @@ convert_constant(op_t op, int arg, type_ nv->v_ldbl = (ot == PTR || is_uinteger(ot)) ? (ldbl_t)(uint64_t)v->v_quad : (ldbl_t)v->v_quad; } else { - rchk = 1; /* Check for lost precision. */ + rchk = true; /* Check for lost precision. */ nv->v_quad = v->v_quad; } } @@ -2319,12 +2323,12 @@ convert_constant(op_t op, int arg, type_ if (v->v_ansiu && is_floating(nt)) { /* ANSI C treats constant as unsigned */ warning(157); - v->v_ansiu = 0; + v->v_ansiu = false; } else if (v->v_ansiu && (is_integer(nt) && !is_uinteger(nt) && psize(nt) > psize(ot))) { /* ANSI C treats constant as unsigned */ warning(157); - v->v_ansiu = 0; + v->v_ansiu = false; } switch (nt) { @@ -2589,7 +2593,7 @@ static tnode_t * build_struct_access(op_t op, tnode_t *ln, tnode_t *rn) { tnode_t *ntn, *ctn; - int nolval; + bool nolval; lint_assert(rn->tn_op == NAME); lint_assert(rn->tn_sym->s_value.v_tspec == INT); @@ -2628,7 +2632,7 @@ build_struct_access(op_t op, tnode_t *ln } if (nolval) - ntn->tn_lvalue = 0; + ntn->tn_lvalue = false; return ntn; } @@ -2680,7 +2684,7 @@ build_real_imag(op_t op, tnode_t *ln) return NULL; } ntn = new_tnode(op, cn->tn_type, ln, cn); - ntn->tn_lvalue = 1; + ntn->tn_lvalue = true; return ntn; } @@ -2688,7 +2692,7 @@ build_real_imag(op_t op, tnode_t *ln) * Create a tree node for the & operator */ static tnode_t * -build_ampersand(tnode_t *tn, int noign) +build_ampersand(tnode_t *tn, bool noign) { tnode_t *ntn; tspec_t t; @@ -2998,7 +3002,7 @@ fold(tnode_t *tn) { val_t *v; tspec_t t; - int utyp, ovfl; + bool utyp, ovfl; int64_t sl, sr = 0, q = 0, mask; uint64_t ul, ur = 0; tnode_t *cn; @@ -3012,7 +3016,7 @@ fold(tnode_t *tn) ur = sr = tn->tn_right->tn_val->v_quad; mask = qlmasks[size(t)]; - ovfl = 0; + ovfl = false; switch (tn->tn_op) { case UPLUS: @@ -3021,7 +3025,7 @@ fold(tnode_t *tn) case UMINUS: q = -sl; if (sl != 0 && msb(q, t, -1) == msb(sl, t, -1)) - ovfl = 1; + ovfl = true; break; case COMPL: q = ~sl; @@ -3030,13 +3034,13 @@ fold(tnode_t *tn) if (utyp) { q = ul * ur; if (q != (q & mask)) - ovfl = 1; + ovfl = true; else if ((ul != 0) && ((q / ul) != ur)) - ovfl = 1; + ovfl = true; } else { q = sl * sr; if (msb(q, t, -1) != (msb(sl, t, -1) ^ msb(sr, t, -1))) - ovfl = 1; + ovfl = true; } break; case DIV: @@ -3061,20 +3065,20 @@ fold(tnode_t *tn) q = utyp ? (int64_t)(ul + ur) : sl + sr; if (msb(sl, t, -1) != 0 && msb(sr, t, -1) != 0) { if (msb(q, t, -1) == 0) - ovfl = 1; + ovfl = true; } else if (msb(sl, t, -1) == 0 && msb(sr, t, -1) == 0) { if (msb(q, t, -1) != 0) - ovfl = 1; + ovfl = true; } break; case MINUS: q = utyp ? (int64_t)(ul - ur) : sl - sr; if (msb(sl, t, -1) != 0 && msb(sr, t, -1) == 0) { if (msb(q, t, -1) == 0) - ovfl = 1; + ovfl = true; } else if (msb(sl, t, -1) == 0 && msb(sr, t, -1) != 0) { if (msb(q, t, -1) != 0) - ovfl = 1; + ovfl = true; } break; case SHL: @@ -3089,22 +3093,22 @@ fold(tnode_t *tn) q = xsign(q, t, size(t) - (int)sr); break; case LT: - q = utyp ? ul < ur : sl < sr; + q = (utyp ? ul < ur : sl < sr) ? 1 : 0; break; case LE: - q = utyp ? ul <= ur : sl <= sr; + q = (utyp ? ul <= ur : sl <= sr) ? 1 : 0; break; case GE: - q = utyp ? ul >= ur : sl >= sr; + q = (utyp ? ul >= ur : sl >= sr) ? 1 : 0; break; case GT: - q = utyp ? ul > ur : sl > sr; + q = (utyp ? ul > ur : sl > sr) ? 1 : 0; break; case EQ: - q = utyp ? ul == ur : sl == sr; + q = (utyp ? ul == ur : sl == sr) ? 1 : 0; break; case NE: - q = utyp ? ul != ur : sl != sr; + q = (utyp ? ul != ur : sl != sr) ? 1 : 0; break; case AND: q = utyp ? (int64_t)(ul & ur) : sl & sr; @@ -3155,13 +3159,13 @@ fold_test(tnode_t *tn) if (hflag && !constcond_flag) /* constant argument to NOT */ warning(239); - v->v_quad = !l; + v->v_quad = !l ? 1 : 0; break; case LOGAND: - v->v_quad = l && r; + v->v_quad = l && r ? 1 : 0; break; case LOGOR: - v->v_quad = l || r; + v->v_quad = l || r ? 1 : 0; break; default: lint_assert(/*CONSTCOND*/0); @@ -3180,7 +3184,7 @@ fold_float(tnode_t *tn) tspec_t t; ldbl_t l, r = 0; - fpe = 0; + fpe = false; v = xcalloc(1, sizeof (val_t)); v->v_tspec = t = tn->tn_type->t_tspec; @@ -3225,29 +3229,29 @@ fold_float(tnode_t *tn) v->v_ldbl = l - r; break; case LT: - v->v_quad = l < r; + v->v_quad = (l < r) ? 1 : 0; break; case LE: - v->v_quad = l <= r; + v->v_quad = (l <= r) ? 1 : 0; break; case GE: - v->v_quad = l >= r; + v->v_quad = (l >= r) ? 1 : 0; break; case GT: - v->v_quad = l > r; + v->v_quad = (l > r) ? 1 : 0; break; case EQ: - v->v_quad = l == r; + v->v_quad = (l == r) ? 1 : 0; break; case NE: - v->v_quad = l != r; + v->v_quad = (l != r) ? 1 : 0; break; default: lint_assert(/*CONSTCOND*/0); } - lint_assert(fpe || !isnan((double)v->v_ldbl)); - if (fpe || !finite((double)v->v_ldbl) || + lint_assert(fpe != 0 || isnan((double)v->v_ldbl) == false); + if (fpe != 0 || finite((double)v->v_ldbl) == false || (t == FLOAT && (v->v_ldbl > FLT_MAX || v->v_ldbl < -FLT_MAX)) || (t == DOUBLE && @@ -3261,7 +3265,7 @@ fold_float(tnode_t *tn) } else { v->v_ldbl = v->v_ldbl < 0 ? -LDBL_MAX: LDBL_MAX; } - fpe = 0; + fpe = false; } return new_constant_node(tn->tn_type, v); @@ -3307,12 +3311,13 @@ build_offsetof(type_t *tp, sym_t *sym) int64_t tsize(type_t *tp) { - int elem, elsz, flex; + int elem, elsz; + bool flex; elem = 1; - flex = 0; + flex = false; while (tp->t_tspec == ARRAY) { - flex = 1; /* allow c99 flex arrays [] [0] */ + flex = true; /* allow c99 flex arrays [] [0] */ elem *= tp->t_dim; tp = tp->t_subt; } @@ -3448,7 +3453,7 @@ cast(tnode_t *tn, type_t *tp) tn = getnode(); tn->tn_op = CVT; tn->tn_type = tp; - tn->tn_cast = 1; + tn->tn_cast = true; tn->tn_right = NULL; return tn; } @@ -3489,7 +3494,7 @@ cast(tnode_t *tn, type_t *tp) } tn = convert(CVT, 0, tp, tn); - tn->tn_cast = 1; + tn->tn_cast = true; return tn; } @@ -3643,14 +3648,15 @@ check_prototype_argument( tnode_t *tn) /* argument */ { tnode_t *ln; - int dowarn; + bool dowarn; ln = xcalloc(1, sizeof (tnode_t)); ln->tn_type = tduptyp(tp); - ln->tn_type->t_const = 0; - ln->tn_lvalue = 1; + ln->tn_type->t_const = false; + ln->tn_lvalue = true; if (typeok(FARG, n, ln, tn)) { - if (!eqtype(tp, tn->tn_type, 1, 0, (dowarn = 0, &dowarn)) || dowarn) + if (!eqtype(tp, tn->tn_type, + true, false, (dowarn = false, &dowarn)) || dowarn) tn = convert(FARG, n, tp, tn); } free(ln); @@ -3663,7 +3669,7 @@ check_prototype_argument( * type, an error message is printed. */ val_t * -constant(tnode_t *tn, int required) +constant(tnode_t *tn, bool required) { val_t *v; @@ -3719,7 +3725,7 @@ constant(tnode_t *tn, int required) * for the expression. */ void -expr(tnode_t *tn, int vctx, int tctx, int dofreeblk) +expr(tnode_t *tn, bool vctx, bool tctx, bool dofreeblk) { lint_assert(tn != NULL || nerr != 0); @@ -3864,12 +3870,12 @@ display_expression(const tnode_t *tn, in */ /* ARGSUSED */ void -check_expr_misc(const tnode_t *tn, int vctx, int tctx, - int eqwarn, int fcall, int rvdisc, int szof) +check_expr_misc(const tnode_t *tn, bool vctx, bool tctx, + bool eqwarn, bool fcall, bool rvdisc, bool szof) { tnode_t *ln, *rn; mod_t *mp; - int nrvdisc, cvctx, ctctx; + bool nrvdisc, cvctx, ctctx; op_t op; scl_t sc; dinfo_t *di; @@ -4009,7 +4015,7 @@ check_expr_misc(const tnode_t *tn, int v * context for both operands of COLON */ if (op == COLON && tn->tn_type->t_tspec == VOID) - cvctx = ctctx = 0; + cvctx = ctctx = false; nrvdisc = op == CVT && tn->tn_type->t_tspec == VOID; check_expr_misc(ln, cvctx, ctctx, mp->m_eqwarn, op == CALL, nrvdisc, szof); @@ -4043,7 +4049,7 @@ check_expr_misc(const tnode_t *tn, int v * after the array. */ static void -check_array_index(tnode_t *tn, int amper) +check_array_index(tnode_t *tn, bool amper) { int dim; tnode_t *ln, *rn; Index: src/usr.bin/xlint/lint2/chk.c diff -u src/usr.bin/xlint/lint2/chk.c:1.33 src/usr.bin/xlint/lint2/chk.c:1.34 --- src/usr.bin/xlint/lint2/chk.c:1.33 Sun Jan 10 00:05:46 2021 +++ src/usr.bin/xlint/lint2/chk.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chk.c,v 1.33 2021/01/10 00:05:46 rillig Exp $ */ +/* $NetBSD: chk.c,v 1.34 2021/01/16 02:40: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.33 2021/01/10 00:05:46 rillig Exp $"); +__RCSID("$NetBSD: chk.c,v 1.34 2021/01/16 02:40:02 rillig Exp $"); #endif #include <ctype.h> @@ -65,9 +65,9 @@ static void badfmt(hte_t *, fcall_t *); static void inconarg(hte_t *, fcall_t *, int); static void tofewarg(hte_t *, fcall_t *); static void tomanyarg(hte_t *, fcall_t *); -static int eqtype(type_t *, type_t *, int, int, int, int *); -static int eqargs(type_t *, type_t *, int *); -static int mnoarg(type_t *, int *); +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 *); /* @@ -79,7 +79,7 @@ mainused(void) hte_t *hte; if ((hte = hsearch("main", 0)) != NULL) - hte->h_used = 1; + hte->h_used = true; } /* @@ -239,7 +239,7 @@ chkvtui(hte_t *hte, sym_t *def, sym_t *d fcall_t *call; char *pos1; type_t *tp1, *tp2; - int dowarn, eq; + bool dowarn, eq; tspec_t t1; if (hte->h_calls == NULL) @@ -253,7 +253,8 @@ chkvtui(hte_t *hte, sym_t *def, sym_t *d t1 = (tp1 = TP(def->s_type)->t_subt)->t_tspec; for (call = hte->h_calls; call != NULL; call = call->f_next) { tp2 = TP(call->f_type)->t_subt; - eq = eqtype(tp1, tp2, 1, 0, 0, (dowarn = 0, &dowarn)); + eq = eqtype(tp1, tp2, + true, false, false, (dowarn = false, &dowarn)); if (!call->f_rused) { /* no return value used */ if ((t1 == STRUCT || t1 == UNION) && !eq) { @@ -298,7 +299,7 @@ chkvtdi(hte_t *hte, sym_t *def, sym_t *d { sym_t *sym; type_t *tp1, *tp2; - int eq, dowarn; + bool eq, dowarn; char *pos1; if (def == NULL) @@ -312,7 +313,7 @@ chkvtdi(hte_t *hte, sym_t *def, sym_t *d if (sym == def) continue; tp2 = TP(sym->s_type); - dowarn = 0; + dowarn = false; if (tp1->t_tspec == FUNC && tp2->t_tspec == FUNC) { eq = eqtype(xt1 = tp1->t_subt, xt2 = tp2->t_subt, 1, 0, 0, &dowarn); @@ -446,7 +447,7 @@ static void chkau(hte_t *hte, int n, sym_t *def, sym_t *decl, pos_t *pos1p, fcall_t *call1, fcall_t *call, type_t *arg1, type_t *arg2) { - int promote, asgn, dowarn; + bool promote, asgn, dowarn; tspec_t t1, t2; arginf_t *ai, *ai1; char *pos1; @@ -470,8 +471,9 @@ chkau(hte_t *hte, int n, sym_t *def, sym */ asgn = def != NULL || (decl != NULL && TP(decl->s_type)->t_proto); - dowarn = 0; - if (eqtype(arg1, arg2, 1, promote, asgn, &dowarn) && (!sflag || !dowarn)) + dowarn = false; + if (eqtype(arg1, arg2, true, promote, asgn, &dowarn) && + (!sflag || !dowarn)) return; /* @@ -601,7 +603,7 @@ printflike(hte_t *hte, fcall_t *call, in { const char *fp; int fc; - int fwidth, prec, left, sign, space, alt, zero; + bool fwidth, prec, left, sign, space, alt, zero; tspec_t sz, t1, t2 = NOTSPEC; type_t *tp; @@ -619,7 +621,7 @@ printflike(hte_t *hte, fcall_t *call, in break; } fc = *fp++; - fwidth = prec = left = sign = space = alt = zero = 0; + fwidth = prec = left = sign = space = alt = zero = false; sz = NOTSPEC; /* Flags */ @@ -627,23 +629,23 @@ printflike(hte_t *hte, fcall_t *call, in if (fc == '-') { if (left) break; - left = 1; + left = true; } else if (fc == '+') { if (sign) break; - sign = 1; + sign = true; } else if (fc == ' ') { if (space) break; - space = 1; + space = true; } else if (fc == '#') { if (alt) break; - alt = 1; + alt = true; } else if (fc == '0') { if (zero) break; - zero = 1; + zero = true; } else { break; } @@ -651,11 +653,11 @@ printflike(hte_t *hte, fcall_t *call, in } /* field width */ - if (isdigit(fc)) { - fwidth = 1; - do { fc = *fp++; } while (isdigit(fc)) ; + if (ch_isdigit(fc)) { + fwidth = true; + do { fc = *fp++; } while (ch_isdigit(fc)); } else if (fc == '*') { - fwidth = 1; + fwidth = true; fc = *fp++; if ((tp = *ap++) == NULL) { tofewarg(hte, call); @@ -669,9 +671,9 @@ printflike(hte_t *hte, fcall_t *call, in /* precision */ if (fc == '.') { fc = *fp++; - prec = 1; - if (isdigit(fc)) { - do { fc = *fp++; } while (isdigit(fc)); + prec = true; + if (ch_isdigit(fc)) { + do { fc = *fp++; } while (ch_isdigit(fc)); } else if (fc == '*') { fc = *fp++; if ((tp = *ap++) == NULL) { @@ -826,7 +828,7 @@ scanflike(hte_t *hte, fcall_t *call, int { const char *fp; int fc; - int noasgn, fwidth; + bool noasgn, fwidth; tspec_t sz, t1 = NOTSPEC, t2 = NOTSPEC; type_t *tp = NULL; @@ -845,17 +847,17 @@ scanflike(hte_t *hte, fcall_t *call, int } fc = *fp++; - noasgn = fwidth = 0; + noasgn = fwidth = false; sz = NOTSPEC; if (fc == '*') { - noasgn = 1; + noasgn = true; fc = *fp++; } - if (isdigit(fc)) { - fwidth = 1; - do { fc = *fp++; } while (isdigit(fc)); + if (ch_isdigit(fc)) { + fwidth = true; + do { fc = *fp++; } while (ch_isdigit(fc)); } if (fc == 'h') { @@ -1066,7 +1068,7 @@ static void chkrvu(hte_t *hte, sym_t *def) { fcall_t *call; - int used, ignored; + bool used, ignored; if (def == NULL) /* don't know whether or not the functions returns a value */ @@ -1090,7 +1092,7 @@ chkrvu(hte_t *hte, sym_t *def) return; /* function has return value */ - used = ignored = 0; + used = ignored = false; for (call = hte->h_calls; call != NULL; call = call->f_next) { used |= call->f_rused || call->f_rdisc; ignored |= !call->f_rused && !call->f_rdisc; @@ -1118,13 +1120,14 @@ chkrvu(hte_t *hte, sym_t *def) static void chkadecl(hte_t *hte, sym_t *def, sym_t *decl) { - int osdef, eq, dowarn, n; + bool osdef, eq, dowarn; + int n; sym_t *sym1, *sym; type_t **ap1, **ap2, *tp1, *tp2; char *pos1; const char *pos2; - osdef = 0; + osdef = false; if (def != NULL) { osdef = def->s_osdef; sym1 = def; @@ -1149,7 +1152,7 @@ chkadecl(hte_t *hte, sym_t *def, sym_t * n = 0; while (*ap1 != NULL && *ap2 != NULL) { type_t *xt1, *xt2; - dowarn = 0; + dowarn = false; eq = eqtype(xt1 = *ap1, xt2 = *ap2, 1, osdef, 0, &dowarn); if (!eq || dowarn) { pos1 = xstrdup(mkpos(&sym1->s_pos)); @@ -1196,8 +1199,9 @@ chkadecl(hte_t *hte, sym_t *def, sym_t * * *dowarn set to 1 if an old style declaration was compared with * an incompatible prototype declaration */ -static int -eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int asgn, int *dowarn) +static bool +eqtype(type_t *tp1, type_t *tp2, bool ignqual, bool promot, bool asgn, + bool *dowarn) { tspec_t t, to; int indir; @@ -1310,7 +1314,7 @@ eqtype(type_t *tp1, type_t *tp2, int ign tp1 = tp1->t_subt; tp2 = tp2->t_subt; - ignqual = promot = 0; + ignqual = promot = false; to = t; indir++; @@ -1322,8 +1326,8 @@ eqtype(type_t *tp1, type_t *tp2, int ign /* * Compares arguments of two prototypes */ -static int -eqargs(type_t *tp1, type_t *tp2, int *dowarn) +static bool +eqargs(type_t *tp1, type_t *tp2, bool *dowarn) { type_t **a1, **a2; @@ -1356,21 +1360,21 @@ eqargs(type_t *tp1, type_t *tp2, int *do * 3. no parameter is converted to another type if integer promotion * is applied on it */ -static int -mnoarg(type_t *tp, int *dowarn) +static bool +mnoarg(type_t *tp, bool *dowarn) { type_t **arg; tspec_t t; if (tp->t_vararg && dowarn != NULL) - *dowarn = 1; + *dowarn = true; for (arg = tp->t_args; *arg != NULL; arg++) { if ((t = (*arg)->t_tspec) == FLOAT) - return 0; + return false; if (t == CHAR || t == SCHAR || t == UCHAR) - return 0; + return false; if (t == SHORT || t == USHORT) - return 0; + return false; } - return 1; + return true; } Index: src/usr.bin/xlint/lint2/externs2.h diff -u src/usr.bin/xlint/lint2/externs2.h:1.8 src/usr.bin/xlint/lint2/externs2.h:1.9 --- src/usr.bin/xlint/lint2/externs2.h:1.8 Fri Jan 18 21:01:39 2002 +++ src/usr.bin/xlint/lint2/externs2.h Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs2.h,v 1.8 2002/01/18 21:01:39 thorpej Exp $ */ +/* $NetBSD: externs2.h,v 1.9 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,22 +35,22 @@ /* * main.c */ -extern int xflag; -extern int uflag; -extern int Cflag; -extern const char *libname; -extern int sflag; -extern int tflag; -extern int Hflag; -extern int hflag; -extern int Fflag; +extern bool xflag; +extern bool uflag; +extern bool Cflag; +extern const char *libname; +extern bool sflag; +extern bool tflag; +extern bool Hflag; +extern bool hflag; +extern bool Fflag; /* * hash.c */ extern void _inithash(hte_t ***); -extern hte_t *_hsearch(hte_t **, const char *, int); +extern hte_t *_hsearch(hte_t **, const char *, bool); extern void _forall(hte_t **, void (*)(hte_t *)); extern void _destroyhash(hte_t **); Index: src/usr.bin/xlint/lint2/hash.c diff -u src/usr.bin/xlint/lint2/hash.c:1.12 src/usr.bin/xlint/lint2/hash.c:1.13 --- src/usr.bin/xlint/lint2/hash.c:1.12 Tue Dec 29 11:35:11 2020 +++ src/usr.bin/xlint/lint2/hash.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.12 2020/12/29 11:35:11 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.13 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: hash.c,v 1.12 2020/12/29 11:35:11 rillig Exp $"); +__RCSID("$NetBSD: hash.c,v 1.13 2021/01/16 02:40:02 rillig Exp $"); #endif /* @@ -91,7 +91,7 @@ hash(const char *s) * given name exists and mknew is set, create a new one. */ hte_t * -_hsearch(hte_t **table, const char *s, int mknew) +_hsearch(hte_t **table, const char *s, bool mknew) { int h; hte_t *hte; @@ -111,9 +111,9 @@ _hsearch(hte_t **table, const char *s, i /* create a new hte */ hte = xmalloc(sizeof (hte_t)); hte->h_name = xstrdup(s); - hte->h_used = 0; - hte->h_def = 0; - hte->h_static = 0; + hte->h_used = false; + hte->h_def = false; + hte->h_static = false; hte->h_syms = NULL; hte->h_lsym = &hte->h_syms; hte->h_calls = NULL; Index: src/usr.bin/xlint/lint2/main2.c diff -u src/usr.bin/xlint/lint2/main2.c:1.12 src/usr.bin/xlint/lint2/main2.c:1.13 --- src/usr.bin/xlint/lint2/main2.c:1.12 Tue Jan 12 21:48:10 2021 +++ src/usr.bin/xlint/lint2/main2.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main2.c,v 1.12 2021/01/12 21:48:10 rillig Exp $ */ +/* $NetBSD: main2.c,v 1.13 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main2.c,v 1.12 2021/01/12 21:48:10 rillig Exp $"); +__RCSID("$NetBSD: main2.c,v 1.13 2021/01/16 02:40:02 rillig Exp $"); #endif #include <stdio.h> @@ -48,46 +48,46 @@ __RCSID("$NetBSD: main2.c,v 1.12 2021/01 #include "lint2.h" /* warnings for symbols which are declared but not defined or used */ -int xflag; +bool xflag; /* * warnings for symbols which are used and not defined or defined * and not used */ -int uflag = 1; +bool uflag = true; /* Create a lint library in the current directory with name libname. */ -int Cflag; -const char *libname; +bool Cflag; +const char *libname; -int pflag; +bool pflag; /* * warnings for (tentative) definitions of the same name in more than * one translation unit */ -int sflag; +bool sflag; bool Tflag; -int tflag; +bool tflag; /* * If a complaint stems from a included file, print the name of the included * file instead of the name specified at the command line followed by '?' */ -int Hflag; +bool Hflag; -int hflag; +bool hflag; /* Print full path names, not only the last component */ -int Fflag; +bool Fflag; /* * List of libraries (from -l flag). These libraries are read after all * other input files has been read and, for Cflag, after the new lint library * has been written. */ -const char **libs; +const char **libs; static void usage(void); @@ -104,39 +104,39 @@ main(int argc, char *argv[]) while ((c = getopt(argc, argv, "hpstxuC:HTFl:")) != -1) { switch (c) { case 's': - sflag = 1; + sflag = true; break; case 'T': Tflag = true; break; case 't': - tflag = 1; + tflag = true; break; case 'u': - uflag = 0; + uflag = false; break; case 'x': - xflag = 1; + xflag = true; break; case 'p': - pflag = 1; + pflag = true; break; case 'C': len = strlen(optarg); lname = xmalloc(len + 10); (void)sprintf(lname, "llib-l%s.ln", optarg); libname = lname; - Cflag = 1; - uflag = 0; + Cflag = true; + uflag = false; break; case 'H': - Hflag = 1; + Hflag = true; break; case 'h': - hflag++; + hflag = true; break; case 'F': - Fflag = 1; + Fflag = true; break; case 'l': for (i = 0; libs[i] != NULL; i++) Index: src/usr.bin/xlint/lint2/msg.c diff -u src/usr.bin/xlint/lint2/msg.c:1.13 src/usr.bin/xlint/lint2/msg.c:1.14 --- src/usr.bin/xlint/lint2/msg.c:1.13 Tue Dec 29 11:35:11 2020 +++ src/usr.bin/xlint/lint2/msg.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.c,v 1.13 2020/12/29 11:35:11 rillig Exp $ */ +/* $NetBSD: msg.c,v 1.14 2021/01/16 02:40:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: msg.c,v 1.13 2020/12/29 11:35:11 rillig Exp $"); +__RCSID("$NetBSD: msg.c,v 1.14 2021/01/16 02:40:02 rillig Exp $"); #endif #include <stdarg.h> @@ -114,7 +114,8 @@ mkpos(pos_t *posp) const char *fn; static char *buf; static size_t blen = 0; - int qm, src, line; + bool qm; + int src, line; if (Hflag && posp->p_src != posp->p_isrc) { src = posp->p_isrc; Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.36 src/usr.bin/xlint/lint2/read.c:1.37 --- src/usr.bin/xlint/lint2/read.c:1.36 Mon Jan 4 22:26:51 2021 +++ src/usr.bin/xlint/lint2/read.c Sat Jan 16 02:40:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.36 2021/01/04 22:26:51 rillig Exp $ */ +/* $NetBSD: read.c,v 1.37 2021/01/16 02:40: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.36 2021/01/04 22:26:51 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.37 2021/01/16 02:40:02 rillig Exp $"); #endif #include <ctype.h> @@ -210,7 +210,7 @@ readfile(const char *name) _destroyhash(renametab); - if (ferror(inp)) + if (ferror(inp) != 0) err(1, "read error on %s", name); (void)fclose(inp); @@ -277,7 +277,7 @@ funccall(pos_t *posp, const char *cp) { arginf_t *ai, **lai; char c, *eptr; - int rused, rdisc; + bool rused, rdisc; hte_t *hte; fcall_t *fcall; const char *name; @@ -286,7 +286,7 @@ funccall(pos_t *posp, const char *cp) fcall->f_pos = *posp; /* read flags */ - rused = rdisc = 0; + rused = rdisc = false; lai = &fcall->f_args; while ((c = *cp) == 'u' || c == 'i' || c == 'd' || c == 'z' || c == 'p' || c == 'n' || c == 's') { @@ -295,7 +295,7 @@ funccall(pos_t *posp, const char *cp) case 'u': if (rused || rdisc) inperr("used or discovered: %c", c); - rused = 1; + rused = true; break; case 'i': if (rused || rdisc) @@ -304,7 +304,7 @@ funccall(pos_t *posp, const char *cp) case 'd': if (rused || rdisc) inperr("used or discovered: %c", c); - rdisc = 1; + rdisc = true; break; case 'z': case 'p': @@ -316,13 +316,13 @@ funccall(pos_t *posp, const char *cp) inperr("bad number: %s", cp); cp = eptr; if (c == 'z') { - ai->a_pcon = ai->a_zero = 1; + ai->a_pcon = ai->a_zero = true; } else if (c == 'p') { - ai->a_pcon = 1; + ai->a_pcon = true; } else if (c == 'n') { - ai->a_ncon = 1; + ai->a_ncon = true; } else { - ai->a_fmt = 1; + ai->a_fmt = true; ai->a_fstrg = inpqstrg(cp, &cp); } *lai = ai; @@ -342,7 +342,7 @@ funccall(pos_t *posp, const char *cp) hte = hte->h_hte; else hte = hsearch(name, 1); - hte->h_used = 1; + hte->h_used = true; fcall->f_type = inptype(cp, &cp); @@ -361,7 +361,7 @@ decldef(pos_t *posp, const char *cp) { sym_t *symp, sym; char c, *ep, *pos1, *tname; - int used, renamed; + bool used, renamed; hte_t *hte, *renamehte = NULL; const char *name, *newname; @@ -369,7 +369,7 @@ decldef(pos_t *posp, const char *cp) sym.s_pos = *posp; sym.s_def = NODECL; - used = 0; + used = false; while (strchr("deiorstuvPS", (c = *cp)) != NULL) { cp++; @@ -387,22 +387,22 @@ decldef(pos_t *posp, const char *cp) case 'i': if (sym.s_inline != NODECL) inperr("inline %c", c); - sym.s_inline = DECL; + sym.s_inline = true; break; case 'o': if (sym.s_osdef) inperr("osdef"); - sym.s_osdef = 1; + sym.s_osdef = true; break; case 'r': if (sym.s_rval) inperr("rval"); - sym.s_rval = 1; + sym.s_rval = true; break; case 's': if (sym.s_static) inperr("static"); - sym.s_static = 1; + sym.s_static = true; break; case 't': if (sym.s_def != NODECL) @@ -412,12 +412,12 @@ decldef(pos_t *posp, const char *cp) case 'u': if (used) inperr("used %c", c); - used = 1; + used = true; break; case 'v': if (sym.s_va) inperr("va"); - sym.s_va = 1; + sym.s_va = true; sym.s_nva = (short)strtol(cp, &ep, 10); if (cp == ep) inperr("bad number: %s", cp); @@ -426,7 +426,7 @@ decldef(pos_t *posp, const char *cp) case 'P': if (sym.s_prfl) inperr("prfl"); - sym.s_prfl = 1; + sym.s_prfl = true; sym.s_nprfl = (short)strtol(cp, &ep, 10); if (cp == ep) inperr("bad number: %s", cp); @@ -435,7 +435,7 @@ decldef(pos_t *posp, const char *cp) case 'S': if (sym.s_scfl) inperr("scfl"); - sym.s_scfl = 1; + sym.s_scfl = true; sym.s_nscfl = (short)strtol(cp, &ep, 10); if (cp == ep) inperr("bad number: %s", cp); @@ -446,7 +446,7 @@ decldef(pos_t *posp, const char *cp) /* read symbol name, doing renaming if necessary */ name = inpname(cp, &cp); - renamed = 0; + renamed = false; if (*cp == 'r') { cp++; tname = xstrdup(name); @@ -457,8 +457,9 @@ decldef(pos_t *posp, const char *cp) if (renamehte->h_hte == NULL) { hte = hsearch(newname, 1); renamehte->h_hte = hte; - renamed = 1; - } else if (strcmp((hte = renamehte->h_hte)->h_name, newname)) { + renamed = true; + } else if (hte = renamehte->h_hte, + strcmp(hte->h_name, newname) != 0) { pos1 = xstrdup(mkpos(&renamehte->h_syms->s_pos)); /* %s renamed multiple times\t%s :: %s */ msg(18, tname, pos1, mkpos(&sym.s_pos)); @@ -475,7 +476,7 @@ decldef(pos_t *posp, const char *cp) } hte->h_used |= used; if (sym.s_def == DEF || sym.s_def == TDEF) - hte->h_def = 1; + hte->h_def = true; sym.s_type = inptype(cp, &cp); @@ -541,7 +542,7 @@ usedsym(pos_t *posp, const char *cp) hte = hte->h_hte; else hte = hsearch(name, 1); - hte->h_used = 1; + hte->h_used = true; *hte->h_lusym = usym; hte->h_lusym = &usym->u_next; @@ -556,7 +557,8 @@ inptype(const char *cp, const char **epp char c, s, *eptr; const char *ep; type_t *tp; - int narg, i, osdef = 0; + int narg, i; + bool osdef = false; size_t tlen; u_short tidx, sidx; int h; @@ -578,9 +580,9 @@ inptype(const char *cp, const char **epp while (c == 'c' || c == 'v') { if (c == 'c') { - tp->t_const = 1; + tp->t_const = true; } else { - tp->t_volatile = 1; + tp->t_volatile = true; } c = *cp++; } @@ -656,16 +658,16 @@ inptype(const char *cp, const char **epp break; case FUNC: c = *cp; - if (isdigit((u_char)c)) { + if (ch_isdigit(c)) { if (!osdef) - tp->t_proto = 1; + tp->t_proto = true; narg = (int)strtol(cp, &eptr, 10); cp = eptr; tp->t_args = xcalloc((size_t)(narg + 1), sizeof (type_t *)); for (i = 0; i < narg; i++) { if (i == narg - 1 && *cp == 'E') { - tp->t_vararg = 1; + tp->t_vararg = true; cp++; } else { sidx = inptype(cp, &cp); @@ -678,21 +680,21 @@ inptype(const char *cp, const char **epp break; case ENUM: tp->t_tspec = INT; - tp->t_isenum = 1; + tp->t_isenum = true; /* FALLTHROUGH */ case STRUCT: case UNION: switch (*cp++) { case '1': - tp->t_istag = 1; + tp->t_istag = true; tp->t_tag = hsearch(inpname(cp, &cp), 1); break; case '2': - tp->t_istynam = 1; + tp->t_istynam = true; tp->t_tynam = hsearch(inpname(cp, &cp), 1); break; case '3': - tp->t_isuniqpos = 1; + tp->t_isuniqpos = true; tp->t_uniqpos.p_line = strtol(cp, &eptr, 10); cp = eptr; cp++; @@ -749,23 +751,24 @@ gettlen(const char *cp, const char **epp const char *cp1; char c, s, *eptr; tspec_t t; - int narg, i, cm, vm; + int narg, i; + bool cm, vm; cp1 = cp; c = *cp++; - cm = vm = 0; + cm = vm = false; while (c == 'c' || c == 'v') { if (c == 'c') { if (cm) inperr("cm: %c", c); - cm = 1; + cm = true; } else { if (vm) inperr("vm: %c", c); - vm = 1; + vm = true; } c = *cp++; } @@ -892,7 +895,7 @@ gettlen(const char *cp, const char **epp break; case FUNC: c = *cp; - if (isdigit((u_char)c)) { + if (ch_isdigit(c)) { narg = (int)strtol(cp, &eptr, 10); cp = eptr; for (i = 0; i < narg; i++) { @@ -1144,7 +1147,7 @@ inpname(const char *cp, const char **epp buf = xrealloc(buf, blen = len + 1); for (i = 0; i < len; i++) { c = *cp++; - if (!isalnum((unsigned char)c) && c != '_') + if (!ch_isalnum(c) && c != '_') inperr("not alnum or _: %c", c); buf[i] = c; } @@ -1193,7 +1196,7 @@ mkstatic(hte_t *hte) fcall_t **callp, *call; usym_t **usymp, *usym; hte_t *nhte; - int ofnd; + bool ofnd; /* Look for first static definition */ for (sym1 = hte->h_syms; sym1 != NULL; sym1 = sym1->s_next) { @@ -1204,24 +1207,24 @@ mkstatic(hte_t *hte) return; /* Do nothing if this name is used only in one translation unit. */ - ofnd = 0; + ofnd = false; for (sym = hte->h_syms; sym != NULL && !ofnd; sym = sym->s_next) { if (sym->s_pos.p_src != sym1->s_pos.p_src) - ofnd = 1; + ofnd = true; } for (call = hte->h_calls; call != NULL && !ofnd; call = call->f_next) { if (call->f_pos.p_src != sym1->s_pos.p_src) - ofnd = 1; + ofnd = true; } for (usym = hte->h_usyms; usym != NULL && !ofnd; usym = usym->u_next) { if (usym->u_pos.p_src != sym1->s_pos.p_src) - ofnd = 1; + ofnd = true; } if (!ofnd) { - hte->h_used = 1; + hte->h_used = true; /* errors about undef. static symbols are printed in lint1 */ - hte->h_def = 1; - hte->h_static = 1; + hte->h_def = true; + hte->h_static = true; return; } @@ -1236,9 +1239,9 @@ mkstatic(hte_t *hte) nhte->h_link = xmalloc(sizeof (hte_t)); nhte = nhte->h_link; nhte->h_name = hte->h_name; - nhte->h_used = 1; - nhte->h_def = 1; /* error in lint1 */ - nhte->h_static = 1; + nhte->h_used = true; + nhte->h_def = true; /* error in lint1 */ + nhte->h_static = true; nhte->h_syms = NULL; nhte->h_lsym = &nhte->h_syms; nhte->h_calls = NULL; @@ -1254,7 +1257,7 @@ mkstatic(hte_t *hte) */ for (symp = &hte->h_syms; (sym = *symp) != NULL; ) { if (sym->s_pos.p_src == sym1->s_pos.p_src) { - sym->s_static = 1; + sym->s_static = true; (*symp) = sym->s_next; if (hte->h_lsym == &sym->s_next) hte->h_lsym = symp; @@ -1291,10 +1294,10 @@ mkstatic(hte_t *hte) } /* h_def must be recalculated for old hte */ - hte->h_def = nhte->h_def = 0; + hte->h_def = nhte->h_def = false; for (sym = hte->h_syms; sym != NULL; sym = sym->s_next) { if (sym->s_def == DEF || sym->s_def == TDEF) { - hte->h_def = 1; + hte->h_def = true; break; } } Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.53 src/usr.bin/xlint/xlint/xlint.c:1.54 --- src/usr.bin/xlint/xlint/xlint.c:1.53 Tue Jan 12 20:42:01 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sat Jan 16 02:40:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.53 2021/01/12 20:42:01 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.54 2021/01/16 02:40:03 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: xlint.c,v 1.53 2021/01/12 20:42:01 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.54 2021/01/16 02:40:03 rillig Exp $"); #endif #include <sys/param.h> @@ -106,7 +106,7 @@ static char **libsrchpath; static char *libexec_path; /* flags */ -static int iflag, oflag, Cflag, sflag, tflag, Fflag, dflag, Bflag, Sflag; +static bool iflag, oflag, Cflag, sflag, tflag, Fflag, dflag, Bflag, Sflag; /* print the commands executed to run the stages of compilation */ static int Vflag; @@ -115,7 +115,7 @@ static int Vflag; static char *outputfn; /* reset after first .c source has been processed */ -static int first = 1; +static bool first = true; /* * name of a file which is currently written by a child and should @@ -388,7 +388,7 @@ main(int argc, char *argv[]) break; case 'F': - Fflag = 1; + Fflag = true; /* FALLTHROUGH */ case 'u': case 'h': @@ -407,7 +407,7 @@ main(int argc, char *argv[]) case 'i': if (Cflag) usage(); - iflag = 1; + iflag = true; break; case 'n': @@ -441,14 +441,14 @@ main(int argc, char *argv[]) appcstrg(&lcflags, "-D__STRICT_ANSI__"); appcstrg(&l1flags, "-s"); appcstrg(&l2flags, "-s"); - sflag = 1; + sflag = true; break; case 'S': if (tflag) usage(); appcstrg(&l1flags, "-S"); - Sflag = 1; + Sflag = true; break; #if ! HAVE_NBTOOL_CONFIG_H @@ -462,7 +462,7 @@ main(int argc, char *argv[]) appstrg(&lcflags, concat2("-D", MACHINE_ARCH)); appcstrg(&l1flags, "-t"); appcstrg(&l2flags, "-t"); - tflag = 1; + tflag = true; break; #endif @@ -473,7 +473,7 @@ main(int argc, char *argv[]) case 'C': if (Cflag || oflag || iflag) usage(); - Cflag = 1; + Cflag = true; appstrg(&l2flags, concat2("-C", optarg)); p2out = xmalloc(sizeof ("llib-l.ln") + strlen(optarg)); (void)sprintf(p2out, "llib-l%s.ln", optarg); @@ -483,7 +483,7 @@ main(int argc, char *argv[]) case 'd': if (dflag) usage(); - dflag = 1; + dflag = true; appcstrg(&cflags, "-nostdinc"); appcstrg(&cflags, "-isystem"); appcstrg(&cflags, optarg); @@ -504,7 +504,7 @@ main(int argc, char *argv[]) case 'o': if (Cflag || oflag) usage(); - oflag = 1; + oflag = true; outputfn = xstrdup(optarg); break; @@ -517,12 +517,12 @@ main(int argc, char *argv[]) break; case 'B': - Bflag = 1; + Bflag = true; libexec_path = xstrdup(optarg); break; case 'V': - Vflag = 1; + Vflag = true; break; case 'Z': @@ -576,7 +576,7 @@ main(int argc, char *argv[]) } else { /* filename */ fname(arg); - first = 0; + first = false; } argc--; argv++; @@ -648,7 +648,7 @@ fname(const char *name) if (oflag) { ofn = outputfn; outputfn = NULL; - oflag = 0; + oflag = false; } else if (iflag) { if (is_stdin) { warnx("-i not supported without -o for standard input");