[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080414113759.GG1540@flint.arm.linux.org.uk>
Date: Mon, 14 Apr 2008 12:37:59 +0100
From: Russell King - ARM Linux <linux@....linux.org.uk>
To: Uwe Kleine-König <Uwe.Kleine-Koenig@...i.com>
Cc: "Hans J. Koch" <hjk@...utronix.de>,
Greg Kroah-Hartman <gregkh@...e.de>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver
On Mon, Apr 14, 2008 at 01:20:21PM +0200, Uwe Kleine-König wrote:
> [1] http://lkml.org/lkml/2008/4/11/81 or
> http://thread.gmane.org/gmane.linux.kernel/665257
In one of the mails, it was said:
No. It's more important to see which variables are declared in the
function and which are declared elsewhere. If you have to search the
whole body of a function for possible declarations, this is BAD. And if
it's not clear where a variable is used, the function is too long or has
other style problems. Your function is short and clean, so where's the
problem? Please move the declaration to the top of the function.
I disagree with this statement. It's far better to limit the scope of
variables so that you know they only have local use, and eg, not used
inside a loop and then outside with possible unintended effects.
If a variable is only used inside a loop, it should be declared _inside_
that loop.
The statement goes on to talk about the function being short and clean -
that's not an argument to apply any particular point of view on this
subject, since you can argue that because it's short and clean you can
see that the variable is only used within the loop.
So, please, keep the variable declaration inside the loop, and don't
pollute the outer levels with unnecessary variable declarations.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists