View | Details | Raw Unified | Return to bug 28555
Collapse All | Expand All

(-)style.9 (-2 / +25 lines)
Lines 449-462 Link Here
449
!(p = f())
449
!(p = f())
450
.Ed
450
.Ed
451
.Pp
451
.Pp
452
Don't use '!' for tests unless it's a boolean, e.g. use
452
For tests, always compare the value to the appropriate 0 instead of
453
checking it directly, unless the value is a boolean.
454
For pointers, use:
455
.Bd -literal
456
if (p != NULL)
457
.Ed
458
.Pp
459
not
460
.PP
461
.Bd -literal
462
if (!p)
463
.Ed
464
.Pp
465
For other values, use:
453
.Bd -literal
466
.Bd -literal
454
if (*p == '\e0')
467
if (*p == '\e0')
455
.Ed
468
.Ed
456
.Pp
469
.Pp
457
not
470
not
458
.Bd -literal
471
.Bd -literal
459
if (!*p)
472
if (*p)
473
.Ed
474
.Pp
475
unless the value is a boolean. In that case, use:
476
.Bd -literal
477
if (p)
478
.Ed
479
.Pp
480
and
481
.Bd -literal
482
if (!p)
460
.Ed
483
.Ed
461
.Pp
484
.Pp
462
Routines returning void * should not have their return values cast
485
Routines returning void * should not have their return values cast

Return to bug 28555