make(1): make a few more bool expressions more precise

The previous version of lint(1) from a few hours ago didn't catch all
occurrences.  And even the current one doesn't catch everything.
Function arguments and return types still need some work.  The "return
quietly" from shouldDieQuietly still implicitly converts from int to
_Bool.

No functional change.
This commit is contained in:
rillig 2021-01-10 23:59:53 +00:00
parent cba96d16f7
commit 810790fcb7
6 changed files with 27 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: filemon_ktrace.c,v 1.11 2021/01/10 21:20:47 rillig Exp $ */
/* $NetBSD: filemon_ktrace.c,v 1.12 2021/01/10 23:59:53 rillig Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@ -519,10 +519,10 @@ top: /* If the child has exited, nothing to do. */
return 0;
/* If we're waiting for input, read some. */
if (F->resid) {
if (F->resid > 0) {
nread = fread(F->p, 1, F->resid, F->in);
if (nread == 0) {
if (feof(F->in))
if (feof(F->in) != 0)
return 0;
assert(ferror(F->in) != 0);
/*
@ -539,7 +539,7 @@ top: /* If the child has exited, nothing to do. */
assert(nread <= F->resid);
F->p += nread;
F->resid -= nread;
if (F->resid) /* may be more events */
if (F->resid > 0) /* may be more events */
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.396 2021/01/10 21:20:46 rillig Exp $ */
/* $NetBSD: job.c,v 1.397 2021/01/10 23:59:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.396 2021/01/10 21:20:46 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.397 2021/01/10 23:59:53 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@ -1539,7 +1539,7 @@ JobMakeArgv(Job *job, char **argv)
(!job->echo ? "" :
(shell->echoFlag != NULL ? shell->echoFlag : "")));
if (args[1]) {
if (args[1] != '\0') {
argv[argc] = args;
argc++;
}
@ -2286,7 +2286,7 @@ Job_Init(void)
static void
DelSig(int sig)
{
if (sigismember(&caught_signals, sig))
if (sigismember(&caught_signals, sig) != 0)
(void)bmake_signal(sig, SIG_DFL);
}
@ -2557,7 +2557,7 @@ JobInterrupt(Boolean runINTERRUPT, int signo)
gn = job->node;
JobDeleteTarget(gn);
if (job->pid) {
if (job->pid != 0) {
DEBUG2(JOB,
"JobInterrupt passing signal %d to child %d.\n",
signo, job->pid);
@ -2728,7 +2728,7 @@ clearfd(Job *job)
* pollfd number should be even.
*/
assert(nfds_per_job() == 2);
if (i % 2)
if (i % 2 != 0)
Punt("odd-numbered fd with meta");
nJobs--;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.511 2021/01/10 21:20:46 rillig Exp $ */
/* $NetBSD: main.c,v 1.512 2021/01/10 23:59:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -110,7 +110,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: main.c,v 1.511 2021/01/10 21:20:46 rillig Exp $");
MAKE_RCSID("$NetBSD: main.c,v 1.512 2021/01/10 23:59:53 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@ -159,7 +159,7 @@ explode(const char *flags)
if (flags == NULL)
return NULL;
for (f = flags; *f; f++)
for (f = flags; *f != '\0'; f++)
if (!ch_isalpha(*f))
break;
@ -243,7 +243,7 @@ parse_debug_options(const char *argvalue)
const char *modules;
DebugFlags debug = opts.debug;
for (modules = argvalue; *modules; ++modules) {
for (modules = argvalue; *modules != '\0'; ++modules) {
switch (*modules) {
case '0': /* undocumented, only intended for tests */
debug = DEBUG_NONE;
@ -790,7 +790,7 @@ str2Lst_Append(StringList *lp, char *str)
const char *sep = " \t";
for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) {
for (n = 0, cp = strtok(str, sep); cp != NULL; cp = strtok(NULL, sep)) {
Lst_Append(lp, cp);
n++;
}
@ -2093,7 +2093,7 @@ shouldDieQuietly(GNode *gn, int bf)
else if (bf >= 0)
quietly = bf;
else
quietly = gn != NULL && (gn->type & OP_MAKE);
quietly = (gn != NULL && (gn->type & OP_MAKE)) ? 1 : 0;
}
return quietly;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.77 2021/01/10 21:20:46 rillig Exp $ */
/* $NetBSD: str.c,v 1.78 2021/01/10 23:59:53 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@ -71,7 +71,7 @@
#include "make.h"
/* "@(#)str.c 5.8 (Berkeley) 6/1/90" */
MAKE_RCSID("$NetBSD: str.c,v 1.77 2021/01/10 21:20:46 rillig Exp $");
MAKE_RCSID("$NetBSD: str.c,v 1.78 2021/01/10 23:59:53 rillig Exp $");
/* Return the concatenation of s1 and s2, freshly allocated. */
char *
@ -161,7 +161,7 @@ Str_Words(const char *str, Boolean expand)
switch (ch) {
case '"':
case '\'':
if (inquote) {
if (inquote != '\0') {
if (inquote == ch)
inquote = '\0';
else
@ -189,7 +189,7 @@ Str_Words(const char *str, Boolean expand)
case ' ':
case '\t':
case '\n':
if (inquote)
if (inquote != '\0')
break;
if (word_start == NULL)
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.159 2020/12/18 15:47:34 rillig Exp $ */
/* $NetBSD: targ.c,v 1.160 2021/01/10 23:59:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -113,7 +113,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: targ.c,v 1.159 2020/12/18 15:47:34 rillig Exp $");
MAKE_RCSID("$NetBSD: targ.c,v 1.160 2021/01/10 23:59:53 rillig Exp $");
/*
* All target nodes that appeared on the left-hand side of one of the
@ -514,7 +514,7 @@ Targ_PrintNode(GNode *gn, int pass)
}
PrintNodeNamesLine("implicit parents", &gn->implicitParents);
} else {
if (gn->unmade)
if (gn->unmade != 0)
debug_printf("# %d unmade children\n", gn->unmade);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.780 2021/01/10 21:20:47 rillig Exp $ */
/* $NetBSD: var.c,v 1.781 2021/01/10 23:59:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -131,7 +131,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: var.c,v 1.780 2021/01/10 21:20:47 rillig Exp $");
MAKE_RCSID("$NetBSD: var.c,v 1.781 2021/01/10 23:59:53 rillig Exp $");
typedef enum VarFlags {
VAR_NONE = 0,
@ -1536,7 +1536,7 @@ tryagain:
args->matched = TRUE;
SepBuf_AddBytes(buf, wp, (size_t)m[0].rm_so);
for (rp = args->replace; *rp; rp++) {
for (rp = args->replace; *rp != '\0'; rp++) {
if (*rp == '\\' && (rp[1] == '&' || rp[1] == '\\')) {
SepBuf_AddBytes(buf, rp + 1, 1);
rp++;
@ -1840,7 +1840,7 @@ VarHash(const char *str)
size_t i;
size_t len;
for (len = len2; len;) {
for (len = len2; len != 0;) {
uint32_t k = 0;
switch (len) {
default: