Module Name: src
Committed By: rillig
Date: Sat Jan 16 16:53:24 UTC 2021
Modified Files:
src/usr.bin/xlint/common: tyname.c
src/usr.bin/xlint/lint1: decl.c emit1.c func.c init.c lint1.h main1.c
tree.c
src/usr.bin/xlint/lint2: chk.c read.c
src/usr.bin/xlint/xlint: xlint.c
Log Message:
lint: replace integer constant expressions with true and false
LINTFLAGS=-gST make lint, with manual review.
The error messages from lint are all correct, they are not complete
though. The return value of a function returning bool may still be
compared to the integer 0.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/common/tyname.c
cvs rdiff -u -r1.123 -r1.124 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/xlint/lint1/tree.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/lint2/chk.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/xlint/lint2/read.c
cvs rdiff -u -r1.55 -r1.56 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/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.23 src/usr.bin/xlint/common/tyname.c:1.24
--- src/usr.bin/xlint/common/tyname.c:1.23 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/common/tyname.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tyname.c,v 1.23 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: tyname.c,v 1.24 2021/01/16 16:53:23 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.23 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.24 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <limits.h>
@@ -50,7 +50,7 @@ __RCSID("$NetBSD: tyname.c,v 1.23 2021/0
do { \
(void)warnx("%s, %d: " fmt, __FILE__, __LINE__, ##args); \
abort(); \
- } while (/*CONSTCOND*/0)
+ } while (/*CONSTCOND*/false)
#endif
/* A tree of strings. */
@@ -228,7 +228,7 @@ sametype(const type_t *t1, const type_t
case FCOMPLEX:
case DCOMPLEX:
case LCOMPLEX:
- return 1;
+ return true;
case ARRAY:
if (t1->t_dim != t2->t_dim)
return false;
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.123 src/usr.bin/xlint/lint1/decl.c:1.124
--- src/usr.bin/xlint/lint1/decl.c:1.123 Sat Jan 16 16:03:46 2021
+++ src/usr.bin/xlint/lint1/decl.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.123 2021/01/16 16:03:46 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.124 2021/01/16 16:53:23 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.123 2021/01/16 16:03:46 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.124 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <sys/param.h>
@@ -177,7 +177,7 @@ incompl(const type_t *tp)
tspec_t t;
if ((t = tp->t_tspec) == VOID) {
- return 1;
+ return true;
} else if (t == ARRAY) {
return tp->t_aincompl;
} else if (t == STRUCT || t == UNION) {
@@ -185,7 +185,7 @@ incompl(const type_t *tp)
} else if (t == ENUM) {
return tp->t_enum->eincompl;
}
- return 0;
+ return false;
}
/*
@@ -661,7 +661,7 @@ popdecl(void)
/* there is nothing after external declarations */
/* FALLTHROUGH */
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
free(di);
}
@@ -1190,7 +1190,7 @@ declarator_1_struct_union(sym_t *dsym)
dcs->d_offset = o;
}
- check_function_definition(dsym, 0);
+ check_function_definition(dsym, false);
/*
* Clear the BITFIELDTYPE indicator after processing each
@@ -1344,7 +1344,7 @@ add_array(sym_t *decl, bool dim, int n)
/* zero sized array is a C99 extension */
c99ism(322);
} else if (n == 0 && !dim) {
- setcomplete(tp, 0);
+ setcomplete(tp, false);
}
return decl;
@@ -1568,7 +1568,7 @@ declarator_name(sym_t *sym)
}
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
sym->s_scl = sc;
@@ -1668,7 +1668,7 @@ mktag(sym_t *tag, tspec_t kind, bool dec
tp->t_enum = getblk(sizeof(*tp->t_enum));
tp->t_enum->etag = tag;
}
- setcomplete(tp, 0);
+ setcomplete(tp, false);
}
return tp;
}
@@ -1751,7 +1751,7 @@ storage_class_name(scl_t sc)
case STRTAG: s = "struct"; break;
case UNIONTAG: s = "union"; break;
case ENUMTAG: s = "enum"; break;
- default: lint_assert(/*CONSTCOND*/0);
+ default: lint_assert(/*CONSTCOND*/false);
}
return s;
}
@@ -1767,7 +1767,7 @@ complete_tag_struct_or_union(type_t *tp,
int n;
sym_t *mem;
- setcomplete(tp, 1);
+ setcomplete(tp, true);
t = tp->t_tspec;
align(dcs->d_stralign, 0);
@@ -1811,7 +1811,7 @@ type_t *
complete_tag_enum(type_t *tp, sym_t *fmem)
{
- setcomplete(tp, 1);
+ setcomplete(tp, true);
tp->t_enum->elem = fmem;
return tp;
}
@@ -1872,7 +1872,7 @@ decl1ext(sym_t *dsym, bool initflg)
bool dowarn, rval, redec;
sym_t *rdsym;
- check_function_definition(dsym, 1);
+ check_function_definition(dsym, true);
check_type(dsym);
@@ -1904,7 +1904,7 @@ decl1ext(sym_t *dsym, bool initflg)
* written as a function definition to the output file.
*/
rval = dsym->s_type->t_subt->t_tspec != VOID;
- outfdef(dsym, &dsym->s_def_pos, rval, 0, NULL);
+ outfdef(dsym, &dsym->s_def_pos, rval, false, NULL);
} else {
outsym(dsym, dsym->s_scl, dsym->s_def);
}
@@ -2034,7 +2034,7 @@ check_redeclaration(sym_t *dsym, bool *d
print_previous_declaration(-1, rsym);
return true;
}
- if (!eqtype(rsym->s_type, dsym->s_type, 0, 0, dowarn)) {
+ if (!eqtype(rsym->s_type, dsym->s_type, false, false, dowarn)) {
/* redeclaration of %s */
error(27, dsym->s_name);
print_previous_declaration(-1, rsym);
@@ -2135,30 +2135,30 @@ eqtype(const type_t *tp1, const type_t *
}
if (t != tp2->t_tspec)
- return 0;
+ return false;
if (!qualifiers_correspond(tp1, tp2, ignqual))
- return 0;
+ return false;
if (t == STRUCT || t == UNION)
return tp1->t_str == tp2->t_str;
if (t == ARRAY && tp1->t_dim != tp2->t_dim) {
if (tp1->t_dim != 0 && tp2->t_dim != 0)
- return 0;
+ return false;
}
/* dont check prototypes for traditional */
if (t == FUNC && !tflag) {
if (tp1->t_proto && tp2->t_proto) {
if (!eqargs(tp1, tp2, dowarn))
- return 0;
+ return false;
} else if (tp1->t_proto) {
if (!mnoarg(tp1, dowarn))
- return 0;
+ return false;
} else if (tp2->t_proto) {
if (!mnoarg(tp2, dowarn))
- return 0;
+ return false;
}
}
@@ -2180,15 +2180,15 @@ eqargs(const type_t *tp1, const type_t *
sym_t *a1, *a2;
if (tp1->t_vararg != tp2->t_vararg)
- return 0;
+ return false;
a1 = tp1->t_args;
a2 = tp2->t_args;
while (a1 != NULL && a2 != NULL) {
- if (eqtype(a1->s_type, a2->s_type, 1, 0, dowarn) == 0)
- return 0;
+ if (eqtype(a1->s_type, a2->s_type, true, false, dowarn) == 0)
+ return false;
a1 = a1->s_next;
a2 = a2->s_next;
@@ -2266,7 +2266,8 @@ check_old_style_definition(sym_t *rdsym,
* If it does not match due to promotion and sflag is
* not set we print only a warning.
*/
- if (!eqtype(arg->s_type, parg->s_type, 1, 1, &dowarn) || dowarn) {
+ if (!eqtype(arg->s_type, parg->s_type, true, true, &dowarn) ||
+ dowarn) {
/* prototype does not match old style defn., arg #%d */
error(299, n);
msg = true;
@@ -2310,7 +2311,7 @@ complete_type(sym_t *dsym, sym_t *ssym)
if (dst->t_dim == 0 && src->t_dim != 0) {
*dstp = dst = duptyp(dst);
dst->t_dim = src->t_dim;
- setcomplete(dst, 1);
+ setcomplete(dst, true);
}
} else if (dst->t_tspec == FUNC) {
if (!dst->t_proto && src->t_proto) {
@@ -2332,7 +2333,7 @@ declare_argument(sym_t *sym, bool initfl
{
tspec_t t;
- check_function_definition(sym, 1);
+ check_function_definition(sym, true);
check_type(sym);
@@ -2536,8 +2537,8 @@ check_prototype_declaration(sym_t *arg,
msg = false;
dowarn = false;
- if (!eqtype(tp, ptp, 1, 1, &dowarn)) {
- if (eqtype(tp, ptp, 1, 0, &dowarn)) {
+ if (!eqtype(tp, ptp, true, true, &dowarn)) {
+ if (eqtype(tp, ptp, true, false, &dowarn)) {
/* type does not match prototype: %s */
gnuism(58, arg->s_name);
msg = sflag || !gflag;
@@ -2601,7 +2602,7 @@ declare_local(sym_t *dsym, bool initflg)
}
}
- check_function_definition(dsym, 1);
+ check_function_definition(dsym, true);
check_type(dsym);
@@ -2647,7 +2648,7 @@ declare_local(sym_t *dsym, bool initflg)
*/
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
} else if (dcs->d_rdcsym->s_blklev == blklev) {
@@ -2731,7 +2732,7 @@ declare_external_in_block(sym_t *dsym)
}
dowarn = false;
- eqt = eqtype(esym->s_type, dsym->s_type, 0, 0, &dowarn);
+ eqt = eqtype(esym->s_type, dsym->s_type, false, false, &dowarn);
if (!eqt || dowarn) {
if (esym->s_scl == EXTERN) {
@@ -2833,7 +2834,7 @@ global_clean_up(void)
* remove all information about pending lint directives without
* warnings.
*/
- global_clean_up_decl(1);
+ global_clean_up_decl(true);
}
/*
@@ -2843,7 +2844,7 @@ sym_t *
declare_1_abstract(sym_t *sym)
{
- check_function_definition(sym, 1);
+ check_function_definition(sym, true);
check_type(sym);
return sym;
}
@@ -3092,7 +3093,7 @@ check_tag_usage(sym_t *sym)
warning(235, sym->s_name);
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
}
Index: src/usr.bin/xlint/lint1/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.37 src/usr.bin/xlint/lint1/emit1.c:1.38
--- src/usr.bin/xlint/lint1/emit1.c:1.37 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint1/emit1.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.37 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.38 2021/01/16 16:53:23 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.37 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.38 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <ctype.h>
@@ -128,7 +128,7 @@ outtype(const type_t *tp)
case DCOMPLEX: t = 'X'; s = '\0'; break;
case LCOMPLEX: t = 'X'; s = 'l'; break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
if (tp->t_const)
outchar('c');
@@ -268,7 +268,7 @@ outsym(const sym_t *sym, scl_t sc, def_t
outchar('e');
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
if (llibflg && def != DECL) {
/*
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.59 src/usr.bin/xlint/lint1/func.c:1.60
--- src/usr.bin/xlint/lint1/func.c:1.59 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint1/func.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.59 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: func.c,v 1.60 2021/01/16 16:53:23 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.59 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.60 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <stdlib.h>
@@ -464,7 +464,7 @@ check_case_label(tnode_t *tn, cstk_t *ci
* get the value of the expression and convert it
* to the type of the switch expression
*/
- v = constant(tn, 1);
+ v = constant(tn, true);
(void) memset(&nv, 0, sizeof nv);
convert_constant(CASE, 0, ci->c_swtype, &nv, v);
free(v);
@@ -542,7 +542,7 @@ check_controlling_expression(tnode_t *tn
if (tn != NULL)
tn = cconv(tn);
if (tn != NULL)
- tn = promote(NOOP, 0, tn);
+ tn = promote(NOOP, false, tn);
if (tn != NULL && !is_scalar(tn->tn_type->t_tspec)) {
/* C99 6.5.15p4 for the ?: operator; see typeok:QUEST */
@@ -572,7 +572,7 @@ if1(tnode_t *tn)
if (tn != NULL)
tn = check_controlling_expression(tn);
if (tn != NULL)
- expr(tn, 0, 1, 0);
+ expr(tn, false, true, false);
pushctrl(T_IF);
}
@@ -616,7 +616,7 @@ switch1(tnode_t *tn)
if (tn != NULL)
tn = cconv(tn);
if (tn != NULL)
- tn = promote(NOOP, 0, tn);
+ tn = promote(NOOP, false, tn);
if (tn != NULL && !is_integer(tn->tn_type->t_tspec)) {
/* switch expression must have integral type */
error(205);
@@ -645,7 +645,7 @@ switch1(tnode_t *tn)
tp->t_tspec = INT;
}
- expr(tn, 1, 0, 1);
+ expr(tn, true, false, true);
pushctrl(T_SWITCH);
cstmt->c_switch = true;
@@ -729,7 +729,7 @@ while1(tnode_t *tn)
if (tn != NULL && tn->tn_op == CON)
cstmt->c_infinite = is_nonzero(tn);
- expr(tn, 0, 1, 1);
+ expr(tn, false, true, true);
}
/*
@@ -792,7 +792,7 @@ do2(tnode_t *tn)
error(323);
}
- expr(tn, 0, 1, 1);
+ expr(tn, false, true, true);
/*
* The end of the loop is only reached if it is no endless loop
@@ -835,12 +835,12 @@ for1(tnode_t *tn1, tnode_t *tn2, tnode_t
cstmt->c_cfpos = csrc_pos;
if (tn1 != NULL)
- expr(tn1, 0, 0, 1);
+ expr(tn1, false, false, true);
if (tn2 != NULL)
tn2 = check_controlling_expression(tn2);
if (tn2 != NULL)
- expr(tn2, 0, 1, 1);
+ expr(tn2, false, true, true);
cstmt->c_infinite =
tn2 == NULL || (tn2->tn_op == CON && is_nonzero(tn2));
@@ -880,7 +880,7 @@ for2(void)
}
if (tn3 != NULL) {
- expr(tn3, 0, 0, 1);
+ expr(tn3, false, false, true);
} else {
tfreeblk();
}
@@ -903,7 +903,7 @@ void
dogoto(sym_t *lab)
{
- mark_as_used(lab, 0, 0);
+ mark_as_used(lab, false, false);
check_statement_reachable();
@@ -1017,7 +1017,7 @@ doreturn(tnode_t *tn)
}
}
- expr(tn, 1, 0, 1);
+ expr(tn, true, false, true);
} else {
Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.62 src/usr.bin/xlint/lint1/init.c:1.63
--- src/usr.bin/xlint/lint1/init.c:1.62 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint1/init.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.62 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: init.c,v 1.63 2021/01/16 16:53:23 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.62 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.63 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <stdlib.h>
@@ -323,7 +323,7 @@ initstack_push(void)
istk->i_remaining = 1;
lint_assert(istk->i_type->t_tspec == ARRAY);
istk->i_type->t_dim++;
- setcomplete(istk->i_type, 1);
+ setcomplete(istk->i_type, true);
}
lint_assert(istk->i_remaining > 0);
@@ -583,7 +583,7 @@ mkinit(tnode_t *tn)
ln->tn_type = tduptyp(ln->tn_type);
ln->tn_type->t_const = false;
tn = build(ASSIGN, ln, tn);
- expr(tn, 0, 0, 0);
+ expr(tn, false, false, false);
return;
}
@@ -627,7 +627,7 @@ mkinit(tnode_t *tn)
* expr() would free it.
*/
tmem = tsave();
- expr(tn, 1, 0, 1);
+ expr(tn, true, false, true);
trestor(tmem);
if (is_integer(lt) && ln->tn_type->t_bitfield && !is_integer(rt)) {
@@ -668,7 +668,7 @@ initstack_string(tnode_t *tn)
strg_t *strg;
if (tn->tn_op != STRING)
- return 0;
+ return false;
istk = initstk;
strg = tn->tn_string;
@@ -683,7 +683,7 @@ initstack_string(tnode_t *tn)
if (!((strg->st_tspec == CHAR &&
(t == CHAR || t == UCHAR || t == SCHAR)) ||
(strg->st_tspec == WCHAR && t == WCHAR))) {
- return 0;
+ return false;
}
/* Put the array at top of stack */
initstack_push();
@@ -694,16 +694,16 @@ initstack_string(tnode_t *tn)
if (!((strg->st_tspec == CHAR &&
(t == CHAR || t == UCHAR || t == SCHAR)) ||
(strg->st_tspec == WCHAR && t == WCHAR))) {
- return 0;
+ return false;
}
/*
* If the array is already partly initialized, we are
* wrong here.
*/
if (istk->i_remaining != istk->i_type->t_dim)
- return 0;
+ return false;
} else {
- return 0;
+ return false;
}
/* Get length without trailing NUL character. */
@@ -712,7 +712,7 @@ initstack_string(tnode_t *tn)
if (istk->i_nolimit) {
istk->i_nolimit = false;
istk->i_type->t_dim = len + 1;
- setcomplete(istk->i_type, 1);
+ setcomplete(istk->i_type, true);
} else {
if (istk->i_type->t_dim < len) {
/* non-null byte ignored in string initializer */
@@ -723,5 +723,5 @@ initstack_string(tnode_t *tn)
/* In every case the array is initialized completely. */
istk->i_remaining = 0;
- return 1;
+ return true;
}
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.56 src/usr.bin/xlint/lint1/lint1.h:1.57
--- src/usr.bin/xlint/lint1/lint1.h:1.56 Sat Jan 16 16:03:46 2021
+++ src/usr.bin/xlint/lint1/lint1.h Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.56 2021/01/16 16:03:46 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.57 2021/01/16 16:53:23 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -71,7 +71,7 @@ typedef struct {
curr_pos.p_uniq++; \
if (curr_pos.p_file == csrc_pos.p_file) \
csrc_pos.p_uniq++; \
- } while (/*CONSTCOND*/0)
+ } while (/*CONSTCOND*/false)
/*
* Strings cannot be referenced to simply by a pointer to its first
@@ -427,7 +427,7 @@ typedef struct err_set {
do { \
if (!(cond)) \
assert_failed(__FILE__, __LINE__, __func__, #cond); \
- } while (/*CONSTCOND*/0)
+ } while (/*CONSTCOND*/false)
#ifdef BLKDEBUG
#define ZERO 0xa5
@@ -451,7 +451,7 @@ check_printf(const char *fmt, ...)
do { \
check_printf(__CONCAT(MSG_, id), ##args); \
(func)(id, ##args); \
- } while (/*CONSTCOND*/0)
+ } while (/*CONSTCOND*/false)
# define error(id, args...) wrap_check_printf(error, id, ##args)
# define warning(id, args...) wrap_check_printf(warning, id, ##args)
Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.36 src/usr.bin/xlint/lint1/main1.c:1.37
--- src/usr.bin/xlint/lint1/main1.c:1.36 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint1/main1.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.36 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.37 2021/01/16 16:53:23 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.36 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.37 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <sys/types.h>
@@ -166,7 +166,7 @@ bltin(void)
static void
sigfpe(int s)
{
- fpe = true;
+ fpe = 1;
}
int
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.156 src/usr.bin/xlint/lint1/tree.c:1.157
--- src/usr.bin/xlint/lint1/tree.c:1.156 Sat Jan 16 16:03:46 2021
+++ src/usr.bin/xlint/lint1/tree.c Sat Jan 16 16:53:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.156 2021/01/16 16:03:46 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.157 2021/01/16 16:53:23 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.156 2021/01/16 16:03:46 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.157 2021/01/16 16:53:23 rillig Exp $");
#endif
#include <float.h>
@@ -2273,7 +2273,7 @@ convert_constant(op_t op, int arg, type_
case LCOMPLEX:
max = LDBL_MAX; min = -LDBL_MAX; break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
if (v->v_ldbl > max || v->v_ldbl < min) {
lint_assert(nt != LDOUBLE);
@@ -3114,7 +3114,7 @@ fold(tnode_t *tn)
q = utyp ? (int64_t)(ul | ur) : sl | sr;
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
/* XXX does not work for quads. */
@@ -3162,7 +3162,7 @@ fold_test(tnode_t *tn)
v->v_quad = l || r ? 1 : 0;
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
return new_constant_node(tn->tn_type, v);
@@ -3178,7 +3178,7 @@ fold_float(tnode_t *tn)
tspec_t t;
ldbl_t l, r = 0;
- fpe = false;
+ fpe = 0;
v = xcalloc(1, sizeof (val_t));
v->v_tspec = t = tn->tn_type->t_tspec;
@@ -3241,7 +3241,7 @@ fold_float(tnode_t *tn)
v->v_quad = (l != r) ? 1 : 0;
break;
default:
- lint_assert(/*CONSTCOND*/0);
+ lint_assert(/*CONSTCOND*/false);
}
lint_assert(fpe != 0 || isnan((double)v->v_ldbl) == false);
@@ -3259,7 +3259,7 @@ fold_float(tnode_t *tn)
} else {
v->v_ldbl = v->v_ldbl < 0 ? -LDBL_MAX: LDBL_MAX;
}
- fpe = false;
+ fpe = 0;
}
return new_constant_node(tn->tn_type, v);
@@ -4263,7 +4263,7 @@ cat_strings(strg_t *strg1, strg_t *strg2
strg1->F = xrealloc(strg1->F, len * sizeof(*strg1->F)); \
(void)memcpy(strg1->F + len1, strg2->F, len2 * sizeof(*strg1->F)); \
free(strg2->F); \
- } while (/*CONSTCOND*/0)
+ } while (/*CONSTCOND*/false)
if (strg1->st_tspec == CHAR)
COPY(st_cp);
Index: src/usr.bin/xlint/lint2/chk.c
diff -u src/usr.bin/xlint/lint2/chk.c:1.34 src/usr.bin/xlint/lint2/chk.c:1.35
--- src/usr.bin/xlint/lint2/chk.c:1.34 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint2/chk.c Sat Jan 16 16:53:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.34 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.35 2021/01/16 16:53:24 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.34 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.35 2021/01/16 16:53:24 rillig Exp $");
#endif
#include <ctype.h>
@@ -78,7 +78,7 @@ mainused(void)
{
hte_t *hte;
- if ((hte = hsearch("main", 0)) != NULL)
+ if ((hte = hsearch("main", false)) != NULL)
hte->h_used = true;
}
@@ -316,9 +316,10 @@ chkvtdi(hte_t *hte, sym_t *def, sym_t *d
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);
+ true, false, false, &dowarn);
} else {
- eq = eqtype(xt1 = tp1, xt2 = tp2, 0, 0, 0, &dowarn);
+ eq = eqtype(xt1 = tp1, xt2 = tp2,
+ false, false, false, &dowarn);
}
if (!eq || (sflag && dowarn)) {
pos1 = xstrdup(mkpos(&def->s_pos));
@@ -1153,7 +1154,8 @@ chkadecl(hte_t *hte, sym_t *def, sym_t *
while (*ap1 != NULL && *ap2 != NULL) {
type_t *xt1, *xt2;
dowarn = false;
- eq = eqtype(xt1 = *ap1, xt2 = *ap2, 1, osdef, 0, &dowarn);
+ eq = eqtype(xt1 = *ap1, xt2 = *ap2,
+ true, osdef, false, &dowarn);
if (!eq || dowarn) {
pos1 = xstrdup(mkpos(&sym1->s_pos));
pos2 = mkpos(&sym->s_pos);
@@ -1229,7 +1231,7 @@ eqtype(type_t *tp1, type_t *tp2, bool ig
if (asgn && to == PTR) {
if (indir == 1 && (t == VOID || tp2->t_tspec == VOID))
- return 1;
+ return true;
}
if (t != tp2->t_tspec) {
@@ -1238,9 +1240,9 @@ eqtype(type_t *tp1, type_t *tp2, bool ig
* signedness a chance if not sflag and not hflag.
*/
if (sflag || hflag || to != PTR)
- return 0;
+ return false;
if (signed_type(t) != signed_type(tp2->t_tspec))
- return 0;
+ return false;
}
if (tp1->t_isenum && tp2->t_isenum) {
@@ -1256,7 +1258,7 @@ eqtype(type_t *tp1, type_t *tp2, bool ig
tp1->t_uniqpos.p_uniq ==
tp2->t_uniqpos.p_uniq);
} else {
- return 0;
+ return false;
}
}
@@ -1267,14 +1269,14 @@ eqtype(type_t *tp1, type_t *tp2, bool ig
if (asgn && indir == 1) {
if (!tp1->t_const && tp2->t_const)
- return 0;
+ return false;
if (!tp1->t_volatile && tp2->t_volatile)
- return 0;
+ return false;
} else if (!ignqual && !tflag) {
if (tp1->t_const != tp2->t_const)
- return 0;
+ return false;
if (tp1->t_const != tp2->t_const)
- return 0;
+ return false;
}
if (t == STRUCT || t == UNION) {
@@ -1290,25 +1292,25 @@ eqtype(type_t *tp1, type_t *tp2, bool ig
tp1->t_uniqpos.p_uniq ==
tp2->t_uniqpos.p_uniq);
} else {
- return 0;
+ return false;
}
}
if (t == ARRAY && tp1->t_dim != tp2->t_dim) {
if (tp1->t_dim != 0 && tp2->t_dim != 0)
- return 0;
+ return false;
}
if (t == FUNC) {
if (tp1->t_proto && tp2->t_proto) {
if (!eqargs(tp1, tp2, dowarn))
- return 0;
+ return false;
} else if (tp1->t_proto) {
if (!mnoarg(tp1, dowarn))
- return 0;
+ return false;
} else if (tp2->t_proto) {
if (!mnoarg(tp2, dowarn))
- return 0;
+ return false;
}
}
@@ -1332,15 +1334,15 @@ eqargs(type_t *tp1, type_t *tp2, bool *d
type_t **a1, **a2;
if (tp1->t_vararg != tp2->t_vararg)
- return 0;
+ return false;
a1 = tp1->t_args;
a2 = tp2->t_args;
while (*a1 != NULL && *a2 != NULL) {
- if (eqtype(*a1, *a2, 1, 0, 0, dowarn) == 0)
- return 0;
+ if (eqtype(*a1, *a2, true, false, false, dowarn) == 0)
+ return false;
a1++;
a2++;
Index: src/usr.bin/xlint/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.37 src/usr.bin/xlint/lint2/read.c:1.38
--- src/usr.bin/xlint/lint2/read.c:1.37 Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint2/read.c Sat Jan 16 16:53:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.37 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: read.c,v 1.38 2021/01/16 16:53:24 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.37 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.38 2021/01/16 16:53:24 rillig Exp $");
#endif
#include <ctype.h>
@@ -337,11 +337,11 @@ funccall(pos_t *posp, const char *cp)
name = inpname(cp, &cp);
/* first look it up in the renaming table, then in the normal table */
- hte = _hsearch(renametab, name, 0);
+ hte = _hsearch(renametab, name, false);
if (hte != NULL)
hte = hte->h_hte;
else
- hte = hsearch(name, 1);
+ hte = hsearch(name, true);
hte->h_used = true;
fcall->f_type = inptype(cp, &cp);
@@ -453,9 +453,9 @@ decldef(pos_t *posp, const char *cp)
newname = inpname(cp, &cp);
/* enter it and see if it's already been renamed */
- renamehte = _hsearch(renametab, tname, 1);
+ renamehte = _hsearch(renametab, tname, true);
if (renamehte->h_hte == NULL) {
- hte = hsearch(newname, 1);
+ hte = hsearch(newname, true);
renamehte->h_hte = hte;
renamed = true;
} else if (hte = renamehte->h_hte,
@@ -468,11 +468,11 @@ decldef(pos_t *posp, const char *cp)
free(tname);
} else {
/* it might be a previously-done rename */
- hte = _hsearch(renametab, name, 0);
+ hte = _hsearch(renametab, name, false);
if (hte != NULL)
hte = hte->h_hte;
else
- hte = hsearch(name, 1);
+ hte = hsearch(name, true);
}
hte->h_used |= used;
if (sym.s_def == DEF || sym.s_def == TDEF)
@@ -537,11 +537,11 @@ usedsym(pos_t *posp, const char *cp)
inperr("bad delim %c", cp[-1]);
name = inpname(cp, &cp);
- hte = _hsearch(renametab, name, 0);
+ hte = _hsearch(renametab, name, false);
if (hte != NULL)
hte = hte->h_hte;
else
- hte = hsearch(name, 1);
+ hte = hsearch(name, true);
hte->h_used = true;
*hte->h_lusym = usym;
@@ -687,11 +687,11 @@ inptype(const char *cp, const char **epp
switch (*cp++) {
case '1':
tp->t_istag = true;
- tp->t_tag = hsearch(inpname(cp, &cp), 1);
+ tp->t_tag = hsearch(inpname(cp, &cp), true);
break;
case '2':
tp->t_istynam = true;
- tp->t_tynam = hsearch(inpname(cp, &cp), 1);
+ tp->t_tynam = hsearch(inpname(cp, &cp), true);
break;
case '3':
tp->t_isuniqpos = true;
Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.55 src/usr.bin/xlint/xlint/xlint.c:1.56
--- src/usr.bin/xlint/xlint/xlint.c:1.55 Sat Jan 16 16:03:46 2021
+++ src/usr.bin/xlint/xlint/xlint.c Sat Jan 16 16:53:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.55 2021/01/16 16:03:46 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.56 2021/01/16 16:53:24 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.55 2021/01/16 16:03:46 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.56 2021/01/16 16:53:24 rillig Exp $");
#endif
#include <sys/param.h>
@@ -109,7 +109,7 @@ static char *libexec_path;
static bool iflag, oflag, Cflag, sflag, tflag, Fflag, dflag, Bflag, Sflag;
/* print the commands executed to run the stages of compilation */
-static int Vflag;
+static bool Vflag;
/* filename for oflag */
static char *outputfn;
@@ -141,7 +141,7 @@ static void usage(void);
static void fname(const char *);
static void runchild(const char *, char *const *, const char *, int);
static void findlibs(char *const *);
-static int rdok(const char *);
+static bool rdok(const char *);
static void lint2(void);
static void cat(char *const *, const char *);
@@ -572,7 +572,7 @@ main(int argc, char *argv[])
usage();
/* NOTREACHED */
}
- if (arg[2])
+ if (arg[2] != '\0')
appcstrg(list, arg + 2);
else if (argc > 1) {
argc--;
@@ -626,10 +626,10 @@ fname(const char *name)
char **args, *ofn, *pathname;
const char *CC;
size_t len;
- int is_stdin;
+ bool is_stdin;
int fd;
- is_stdin = (strcmp(name, "-") == 0);
+ is_stdin = strcmp(name, "-") == 0;
bn = lbasename(name, '/');
suff = lbasename(bn, '.');
@@ -680,7 +680,7 @@ fname(const char *name)
if ((CC = getenv("CC")) == NULL)
CC = DEFAULT_CC;
if ((pathname = findcc(CC)) == NULL)
- if (!setenv("PATH", DEFAULT_PATH, 1))
+ if (setenv("PATH", DEFAULT_PATH, 1) == 0)
pathname = findcc(CC);
if (pathname == NULL) {
(void)fprintf(stderr, "%s: %s: not found\n", getprogname(), CC);
@@ -825,18 +825,18 @@ findlibs(char *const *liblst)
free(lfn);
}
-static int
+static bool
rdok(const char *path)
{
struct stat sbuf;
if (stat(path, &sbuf) == -1)
- return 0;
+ return false;
if (!S_ISREG(sbuf.st_mode))
- return 0;
+ return false;
if (access(path, R_OK) == -1)
- return 0;
- return 1;
+ return false;
+ return true;
}
static void