From owner-cvs-all Mon Oct 29 8:20: 5 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 71DE837B407; Mon, 29 Oct 2001 08:19:46 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id DAA29316; Tue, 30 Oct 2001 03:19:30 +1100 Date: Tue, 30 Oct 2001 03:18:31 +1100 (EST) From: Bruce Evans X-X-Sender: To: Luigi Rizzo Cc: "Andrew R. Reiter" , Josef Karthauser , , Subject: Re: ipfw.c -- (was: cvs commit: src/sys/netinet ip_fw.h) In-Reply-To: <20011029000216.A95875@iguana.aciri.org> Message-ID: <20011030030505.J12580-100000@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 29 Oct 2001, Luigi Rizzo wrote: > On Mon, Oct 29, 2001 at 01:05:44AM -0500, Andrew R. Reiter wrote: > > On Sun, 28 Oct 2001, Luigi Rizzo wrote: > > : > > :i seem to remember something about variable scoping in the style(9) > > :manpage, but i cannot find it anymore in FreeBSD 4.3. > > > > In 4.4-RELEASE, style.9 says: > > > > Parts of a for loop may be left empty. Don't put declarations inside > > blocks unless the routine is unusually complicated. > > oh yes, that was it. Well, I think that in the above section of style(9), > the only reasonable interpretation of "the routine" is > "the function in which the block is contained"; otherwise, you > should assume that you are not supposed to use local variables > in small functions! I think the only reasonable interpretation is that style(9) is poorly worded. "blocks" means "inner blocks like the for loop immediately following this paragraph". > > In ipfw.c, there are a number of areas in which it does not make sense, in > > terms of style.9, to declare a variable as local to the point where it's > > no longer at the head of a function. Ie: > > I think this is exactly the case where it makes a lot of sense to > declare vars locally to the block: the start of the function is > far away, there is a bunch of small conditionals where each > of them needs to use some temporary variable and those variables > are meant to be used only within the block. The rule is certainly mean to disallow this. There are very few examples of it being broken in core kernel code (about 8 for int variables in /sys/kern in Lite2). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message