svn commit: r362217 - head/stand/common

Rodney W. Grimes freebsd at gndrsh.dnsmgr.net
Wed Jun 17 16:05:37 UTC 2020


[ Charset UTF-8 unsupported, converting... ]
> On Tue, Jun 16, 2020 at 8:33 PM Ian Lepore <ian at freebsd.org> wrote:
> 
> > On Tue, 2020-06-16 at 19:34 +0200, Kristof Provost wrote:
> > > On 16 Jun 2020, at 19:11, Ed Maste wrote:
> > > > On Tue, 16 Jun 2020 at 13:01, Ian Lepore <ian at freebsd.org> wrote:
> > > > >
> > > > > As much as I prefer doing it this way, style(9) doesn't allow for
> > > > > variable declarations inside a for() statement (or even inside a
> > > > > local
> > > > > block, which is just too 1980s for me, but it is still our standard).
> > > >
> > > > Perhaps it's time to update style(9) to at least permit these uses, as
> > > > we've done with the blank line at the beginning of functions with no
> > > > local variables, and with braces around single-line bodies.
> > >
> > > We have 431 instances of `for (int i` in sys alone. It?s not so much a
> > > question of allowing it as acknowledging reality at this point.
> > >
> > > Best regards,
> > > Kristof
> >
> > Hmm, so we do.  If you weed out sys/contrib, and device drivers
> > contributed by vendors, the number is a lot smaller, but still big
> > enough that we should just change the rules I think.
> >
> 
> We should definitely just change the rules. There's no point in
> prohibiting it. Contributors have already voted with their feet
> 
> diff --git a/share/man/man9/style.9 b/share/man/man9/style.9
> index 4e801bbcbe70..fd23d573eb00 100644
> --- a/share/man/man9/style.9
> +++ b/share/man/man9/style.9
> @@ -592,8 +592,6 @@ not
>  Parts of a
>  .Ic for
>  loop may be left empty.
> -Do not put declarations
> -inside blocks unless the routine is unusually complicated.

Perhaps some wording here that makes it explicit that
block scope variables are allowed, and that the for()
case is allowed.

>  .Bd -literal
>         for (; cnt < 15; cnt++) {
+	for (int cnt = 0; cnt < 15; cnt++) {
+		char *p;
>                 stmt1;

This updates the example to reflect the new accepted style.

> 
> Although the block doesn't start until { so int i; in the commit
> technically doesn't violate this rule. We violate it in dozens of other
> ways than this.

I think it violates some other rule about declarations being
in order of size sorted at the top of a routine, perhaps that
needs looked at as well for some change.

> Warner
-- 
Rod Grimes                                                 rgrimes at freebsd.org


More information about the svn-src-head mailing list