Bug 28555

Summary: [PATCH] style(9) isn't explicit about booleans for testing.
Product: Documentation Reporter: mwm
Component: Books & ArticlesAssignee: Tom Rhodes <trhodes>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description mwm 2001-06-30 22:30:01 UTC
The style(9) page says not to use ! for testing values unless the
value is a boolean. It also says to test pointers against NULL. This
leaves open the question of how other values that aren't booleans
should be tested.

Fix: Apply the attached page to the style(9) man page.
How-To-Repeat: 
Read the man page to try and decide if you should write "if (x)" or
if (x != 0).
Comment 1 dima 2001-06-30 22:57:49 UTC
Mike Meyer <mwm@mired.org> writes:
> 
> >Number:         28555
> >Category:       docs
> >Synopsis:       [PATCH] style(9) isn't explicit about booleans for testing.
> >Description:
> 
> The style(9) page says not to use ! for testing values unless the
> value is a boolean. It also says to test pointers against NULL. This
> leaves open the question of how other values that aren't booleans
> should be tested.
> 
> >How-To-Repeat:
> 
> Read the man page to try and decide if you should write "if (x)" or
> if (x != 0).

I think it is quite clear on the subject.  If it's not a boolean,
don't treat it like one; i.e., compare it against the value you're
looking for.  '0' may not always be that value.

Regardless, this does not belong as a PR, let alone in the docs/
category.  It belongs as a post on -hackers, asking what people think,
not as a change request.  Since *developers* are expected to follow
style(9), it is the *developers* (i.e., -hackers@) that you should be
proposing the change to.

					Dima Dorfman
					dima@unixfreak.org
Comment 2 mwm 2001-06-30 23:55:10 UTC
Dima Dorfman <dima@unixfreak.org> types:
> Mike Meyer <mwm@mired.org> writes:
> > 
> > >Number:         28555
> > >Category:       docs
> > >Synopsis:       [PATCH] style(9) isn't explicit about booleans for testing.
> > >Description:
> > 
> > The style(9) page says not to use ! for testing values unless the
> > value is a boolean. It also says to test pointers against NULL. This
> > leaves open the question of how other values that aren't booleans
> > should be tested.
> > 
> > >How-To-Repeat:
> > 
> > Read the man page to try and decide if you should write "if (x)" or
> > if (x != 0).
> I think it is quite clear on the subject.  If it's not a boolean,
> don't treat it like one; i.e., compare it against the value you're
> looking for.  '0' may not always be that value.

I did overstated the case in the description. I agree that it's clear
on the subject; I think it needs to be made explicit.

> Regardless, this does not belong as a PR, let alone in the docs/
> category.  It belongs as a post on -hackers, asking what people think,
> not as a change request.  Since *developers* are expected to follow
> style(9), it is the *developers* (i.e., -hackers@) that you should be
> proposing the change to.

We both agree I'm not proposing a change in the style they have to
follow; I'm just proposing making something explicit instead of
implicit. As such, I'm not sure it warrants discussion. If the PR
belongs in another category, please feel free to move it to either
move it or suggest one for someone else to move it to.

	Thanx,
	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Comment 3 dima 2001-07-03 00:13:26 UTC
Mike Meyer <mwm@mired.org> writes:
> Dima Dorfman <dima@unixfreak.org> types:
> > Regardless, this does not belong as a PR, let alone in the docs/
> > category.  It belongs as a post on -hackers, asking what people think,
> > not as a change request.  Since *developers* are expected to follow
> > style(9), it is the *developers* (i.e., -hackers@) that you should be
> > proposing the change to.
> 
> We both agree I'm not proposing a change in the style they have to
> follow; I'm just proposing making something explicit instead of
> implicit. As such, I'm not sure it warrants discussion.

I'm not suggesting that you should get every developer's approval, but
I am suggesting that wider review than the -doc list would be nice,
esp. for a document that defines policy.

					Dima Dorfman
					dima@unixfreak.org
Comment 4 Tom Rhodes freebsd_committer freebsd_triage 2002-11-07 04:57:58 UTC
Responsible Changed
From-To: freebsd-doc->trhodes

I'll take this.
Comment 5 Tom Rhodes freebsd_committer freebsd_triage 2006-07-07 04:33:46 UTC
State Changed
From-To: open->closed

This should have been closed a good while ago.  We do not 
need an example of every type of 0.  Furthermore, the current 
version of style(9) is correct and the suggested patch seems 
to be getting the tests in both of the examples backwards 
starting from a non-backwards example of '0'. 

If wording is that large of an issue, please bring it up 
on the mailing lists.  Thanks!