diff options
| author | rillig <rillig@NetBSD.org> | 2021-01-10 21:20:46 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2021-01-10 21:20:46 +0000 |
| commit | e2f1e075b9ff265e598a2ee770a4dd6e1ef176b4 (patch) | |
| tree | 89c026775e3c63d035b9e4ac4097a37c535148d2 /usr.bin/make/for.c | |
| parent | 63d67c64a26461b24ecf7d3661c4845dd96784be (diff) | |
make(1): consistently use boolean expressions in conditions
Most of the make code already followed the style of explicitly writing
(ptr != NULL) instead of the shorter (ptr) in conditions.
The remaining 50 instances have been found by an experimental,
unpublished check in lint(1) that treats bool expressions as
incompatible to any other scalar type, just as in Java, C#, Pascal and
several other languages.
The only unsafe operation on Boolean that is left over is (flags &
FLAG), for an enum implementing a bit set. If Boolean is an ordinary
integer type (the default), some high bits may get lost. But if Boolean
is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2
defines that a conversion from any scalar to the type _Bool acts as a
comparison to 0, which cannot lose any bits.
Diffstat (limited to 'usr.bin/make/for.c')
| -rw-r--r-- | usr.bin/make/for.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index bf83a40d848..af55179dee8 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.133 2021/01/09 16:06:09 rillig Exp $ */ +/* $NetBSD: for.c,v 1.134 2021/01/10 21:20:46 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -58,7 +58,7 @@ #include "make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.133 2021/01/09 16:06:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.134 2021/01/10 21:20:46 rillig Exp $"); static int forLevel = 0; /* Nesting level */ @@ -222,7 +222,7 @@ For_Eval(const char *line) size_t nitems, nvars; if ((nitems = f->items.len) > 0 && - nitems % (nvars = f->vars.len)) { + nitems % (nvars = f->vars.len) != 0) { Parse_Error(PARSE_FATAL, "Wrong number of words (%u) in .for " "substitution list with %u variables", |
