From owner-svn-src-all@freebsd.org Wed Jun 17 16:05:36 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF567352076; Wed, 17 Jun 2020 16:05:36 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49n8zz3dL2z40BK; Wed, 17 Jun 2020 16:05:34 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 05HG5RKv085965; Wed, 17 Jun 2020 09:05:27 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 05HG5Rtu085964; Wed, 17 Jun 2020 09:05:27 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202006171605.05HG5Rtu085964@gndrsh.dnsmgr.net> Subject: Re: svn commit: r362217 - head/stand/common In-Reply-To: To: Warner Losh Date: Wed, 17 Jun 2020 09:05:27 -0700 (PDT) CC: Ian Lepore , Kristof Provost , Ed Maste , Toomas Soome , src-committers , svn-src-all , svn-src-head Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 49n8zz3dL2z40BK X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@gndrsh.dnsmgr.net has no SPF policy when checking 69.59.192.140) smtp.mailfrom=freebsd@gndrsh.dnsmgr.net X-Spamd-Result: default: False [2.26 / 15.00]; HAS_REPLYTO(0.00)[rgrimes@freebsd.org]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.25)[0.246]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; DMARC_NA(0.00)[dnsmgr.net]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.66)[0.664]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_SPAM_LONG(0.45)[0.453]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_TLS_LAST(0.00)[]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13868, ipnet:69.59.192.0/19, country:US]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 16:05:37 -0000 [ Charset UTF-8 unsupported, converting... ] > On Tue, Jun 16, 2020 at 8:33 PM Ian Lepore 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 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@freebsd.org