Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Oct 2001 21:59:38 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Ruslan Ermilov <ru@FreeBSD.ORG>
Cc:        Mark Murray <mark@grondar.za>, <arch@FreeBSD.ORG>
Subject:   Re: [Patch] style.9 nit
Message-ID:  <20011002212531.O87836-100000@delplex.bde.org>
In-Reply-To: <20011002114936.L74839@sunbay.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2 Oct 2001, Ruslan Ermilov wrote:

> On Mon, Oct 01, 2001 at 05:48:42PM +0100, Mark Murray wrote:
> > Hi
> >
> > Any objections to this patch?

Yes.

> > It removes argument names from an example function prototype
> > to match a previously mentioned guideline about such names.
> >
> > eg:
> >
> > int foo(int bar);
> >
> > becomes
> >
> > int foo(int);
> >
> Hmm, what's wrong with this?
>
> :      In header files visible to userland applications, prototypes that are
> :      visible must use either protected names or no names with the types.  It
> :      is preferable to use protected names.  E.g., use:

My version of style.9 clarifies this a little:

%%%
Index: style.9
===================================================================
RCS file: /home/ncvs/src/share/man/man9/style.9,v
retrieving revision 1.66
diff -u -2 -r1.66 style.9
--- style.9	1 Oct 2001 16:13:59 -0000	1.66
+++ style.9	2 Oct 2001 10:59:56 -0000
@@ -238,5 +293,7 @@
 .Pp
 In header files visible to userland applications, prototypes that are
-visible must use either protected names or no names with the types.  It
+visible must use either
+.Dq Li protected
+names (ones beginning with an underscore) or no names with the types.  It
 is preferable to use protected names.
 E.g., use:
%%%

> :
> :      void    function(int);
> :
> :      or:
> :
> :      void    function(int _fd);
>
> Your diff actually changes:
>
> int foo(int _bar);
>
> to
>
> int foo(int);
>
> which is acceptable prototype with "protected" names.

Except this changes from the preferred form to the unpreferred one.

The diff is actually a little different:

> > -static char	*function(int _arg, const char *_arg2, struct foo *_arg3,
> > -		    struct bar *_arg4);
> > +static char	*function(int, const char *, struct foo *, struct bar *);

Since the function is static, this example is bad for other reasons.
Namespace pollution is almost irrelevant.  The function proper must have
certain arg names and those should normally not begin with an underscore
or shadow any more global names.  The function prototype can use the
same names.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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