Page MenuHomeFreeBSD

style.9: be explicit about booleans in comparisons
ClosedPublic

Authored by emaste on May 27 2021, 1:32 PM.
Tags
None
Referenced Files
F102982751: D30507.diff
Tue, Nov 19, 11:26 AM
Unknown Object (File)
Sun, Nov 17, 10:07 AM
Unknown Object (File)
Sun, Nov 17, 10:02 AM
Unknown Object (File)
Thu, Nov 14, 5:44 PM
Unknown Object (File)
Thu, Nov 14, 4:26 PM
Unknown Object (File)
Thu, Nov 14, 9:53 AM
Unknown Object (File)
Wed, Nov 13, 4:49 PM
Unknown Object (File)
Tue, Nov 12, 5:56 PM
Subscribers
None

Details

Summary

We prefer if (count > 0) to if (count) (non-boolean variables) but this is not mentioned in style.9. Make it explicit.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste created this revision.

Maybe should downgrade the statement to something like "if (count > 0) is preferred over if (count)"

share/man/man9/style.9
762

s/Use/Prefer

Incorporate imp's feedback and reword sentence slightly

Reword sentence once more to tie in better to the example

I'm good either way: with or without my suggestion.

This revision is now accepted and ready to land.May 27 2021, 2:06 PM

hit approve on earlier version, but I like the current one even better.