svn commit: r216422 - head/usr.bin/printf
Bruce Evans
brde at optusnet.com.au
Wed Dec 15 12:18:06 UTC 2010
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 at 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
More information about the svn-src-all
mailing list