Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Oct 2001 00:02:16 -0800
From:      Luigi Rizzo <rizzo@aciri.org>
To:        "Andrew R. Reiter" <arr@watson.org>
Cc:        Josef Karthauser <joe@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: ipfw.c -- (was: cvs commit: src/sys/netinet ip_fw.h)
Message-ID:  <20011029000216.A95875@iguana.aciri.org>
In-Reply-To: <Pine.NEB.3.96L.1011029010151.33440A-100000@fledge.watson.org>
References:  <20011028215038.C94510@iguana.aciri.org> <Pine.NEB.3.96L.1011029010151.33440A-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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!

> 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.

	cheers
	luigi
----------------------------------+-----------------------------------------
 Luigi RIZZO, luigi@iet.unipi.it  . ACIRI/ICSI (on leave from Univ. di Pisa)
 http://www.iet.unipi.it/~luigi/  . 1947 Center St, Berkeley CA 94704
 Phone: (510) 666 2927
----------------------------------+-----------------------------------------

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




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