Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 2010 23:18:01 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Pawel Jakub Dawidek <pjd@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Xin LI <delphij@FreeBSD.org>, Bruce Evans <brde@optusnet.com.au>
Subject:   Re: svn commit: r216422 - head/usr.bin/printf
Message-ID:  <20101215231704.K1360@besplex.bde.org>
In-Reply-To: <20101214160438.GF1715@garage.freebsd.pl>
References:  <201012140021.oBE0LZI9097999@svn.freebsd.org> <20101214183752.L870@besplex.bde.org> <20101214160438.GF1715@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 14 Dec 2010, Pawel Jakub Dawidek wrote:

> On Tue, Dec 14, 2010 at 07:26:13PM +1100, Bruce Evans wrote:
>> (*) Reading between the lines, I wilfully misinterpret this example of
>> being a bad example of everthing it does:
>>
>> %      Exits should be 0 on success, or according to the predefined values
>> in
>> %      sysexits(3).
>> %
>> %              exit(EX_OK);    /*
>> %                               * Avoid obvious comments such as
>> %                               * "Exit 0 on success."
>> %                               */
>>
>> Things not to do that are done in this example include:
>> - use EX_OK, not 0 on success
>> - place comments to the right of the code and extend them across multiple
>>   lines for maximal waste of space
>> - when changing code to use EX_OK (or anything, be sure to neglect to change
>>   the comments, so that the comments don't match the code).  [Here this was
>>   originally just a bad example of an obvious comment.  The code said
>>   exit(0)
>>   and the comment said 0 too.  Now it doesn't say EX_OK, so it is not so
>>   obvious that this is an obvious comment (in fact, EX_OK does equal 0,
>>   but this is of no interest here).]
>> This example could be further improved by adding an obvious NOTREACHED
>> comment to it.
>
> I think I've a fix for this. Could you please review the patch below?
>
> Index: share/man/man9/style.9
> ===================================================================
> --- share/man/man9/style.9	(wersja 215409)
> +++ share/man/man9/style.9	(kopia robocza)
> @@ -1,5 +1,6 @@
> .\"-
> .\" Copyright (c) 1995-2005 The FreeBSD Project
> +.\" Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
> .\" All rights reserved.
> .\"
> .\" Redistribution and use in source and binary forms, with or without
> @@ -26,7 +27,7 @@
> .\"	From: @(#)style	1.14 (Berkeley) 4/28/95
> .\" $FreeBSD$
> .\"
> -.Dd December 17, 2008
> +.Dd December 14, 2010
> .Dt STYLE 9
> .Os
> .Sh NAME
> @@ -611,6 +612,9 @@
> 			 * Avoid obvious comments such as
> 			 * "Exit 0 on success."
> 			 */
> +	/*
> +	 * NOTREACHED
> +	 */
> }
> .Ed
> .Pp

I think it is not so obviosly wrong as to be an example of what not to do.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101215231704.K1360>