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/parse.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/parse.c')
| -rw-r--r-- | usr.bin/make/parse.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 61597f679ee..9d41bc0b880 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.525 2020/12/31 17:39:36 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.526 2021/01/10 21:20:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.525 2020/12/31 17:39:36 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.526 2021/01/10 21:20:46 rillig Exp $"); /* types and constants */ @@ -2218,7 +2218,7 @@ ParseDoInclude(char *line /* XXX: bad name */) endc = '"'; /* Skip to matching delimiter */ - for (cp = ++file; *cp && *cp != endc; cp++) + for (cp = ++file; *cp != '\0' && *cp != endc; cp++) continue; if (*cp != endc) { @@ -2508,7 +2508,7 @@ ParseGmakeExport(char *line) pp_skip_whitespace(&variable); - for (value = variable; *value && *value != '='; value++) + for (value = variable; *value != '\0' && *value != '='; value++) continue; if (*value != '=') { |
