Use of bool / stdbool.h in kernel
Dag-Erling Smørgrav
des at des.no
Tue Dec 6 15:13:43 UTC 2011
Rick Macklem <rmacklem at uoguelph.ca> writes:
> If this is added, would the style gods approve of the following:
>
> (A) bool test_func();
>
> if (test_func())
> ...
>
> instead of:
>
> (B) int test_func();
>
> if (test_func() != 0)
> ...
Part of the problem is that the opposite semantics are widely used,
i.e. 0 indicates success and non-zero indicates failure, possibly with
different non-zero values having different specific meanings. There are
also cases (such as open() and socket()) where >= 0 indicates success
while < 0 indicates failure. Therefore, an explicit comparison is
preferred, except for functions like isspace() and the like whose names
clearly indicate that they are predicates.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-arch
mailing list