Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Russell King - ARM Linux
Date: Monday, April 14, 2008 - 4:37 am

On Mon, Apr 14, 2008 at 01:20:21PM +0200, Uwe Kleine-König wrote:

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.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/4] UIO: fixes, cleanups and a new driver, Uwe Kleine-König, (Thu Apr 10, 5:36 am)
[PATCH 1/4] UIO: hold a reference to the device's owner wh ..., Uwe Kleine-König, (Thu Apr 10, 5:37 am)
[PATCH 2/4] UIO: use menuconfig, Uwe Kleine-König, (Thu Apr 10, 5:37 am)
[PATCH 4/4] [RFC] UIO: generic platform driver, Uwe Kleine-König, (Thu Apr 10, 5:37 am)
Re: [PATCH 2/4] UIO: use menuconfig, Hans J. Koch, (Thu Apr 10, 12:39 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Thu Apr 10, 12:54 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Thu Apr 10, 2:17 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Thu Apr 10, 3:48 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Ben Nizette, (Thu Apr 10, 6:34 pm)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 2:24 am)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 3:33 am)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 4:17 am)
Re: [PATCH 4/4] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 12:59 pm)
Re: [PATCH 2/4] UIO: use menuconfig, Greg KH, (Fri Apr 11, 2:36 pm)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Hans J. Koch, (Fri Apr 11, 3:54 pm)
Re: [PATCH 2/4] UIO: use menuconfig, Hans J. Koch, (Fri Apr 11, 3:58 pm)
Re: [PATCH 4/4 v2] [RFC] UIO: generic platform driver, Russell King - ARM Linux, (Sat Apr 12, 6:16 am)
Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform ..., Russell King - ARM Linux, (Mon Apr 14, 2:37 am)
Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform ..., Russell King - ARM Linux, (Mon Apr 14, 3:17 am)
Re: [PATCH] Re: [PATCH 4/4 v2] [RFC] UIO: generic platform ..., Russell King - ARM Linux, (Mon Apr 14, 4:37 am)
[PATCH 1/3] UIO: don't let UIO_CIF and UIO_SMX depend twic ..., Uwe Kleine-König, (Tue Apr 22, 2:52 am)
[PATCH 2/3] provide a dummy implementation of the clk API, Uwe Kleine-König, (Tue Apr 22, 2:52 am)
[PATCH 3/3] UIO: generic platform driver, Uwe Kleine-König, (Tue Apr 22, 2:52 am)
Re: [PATCH 3/3] UIO: generic platform driver, Ben Nizette, (Tue Apr 22, 3:26 am)
Re: [PATCH 3/3] UIO: generic platform driver, Hans J. Koch, (Tue Apr 22, 6:35 am)
Re: [PATCH 0/3] UIO: cleanup and platform driver, Hans J. Koch, (Tue Apr 22, 6:39 am)
Re: [PATCH 3/3] UIO: generic platform driver, Hans J. Koch, (Sun Apr 27, 10:12 am)
[PATCH] UIO: don't let UIO_CIF and UIO_SMX depend twice on UIO, Uwe Kleine-König, (Tue May 20, 2:24 am)
[PATCH] UIO: generic platform driver, Uwe Kleine-König, (Tue May 20, 2:24 am)
Re: [PATCH] UIO: generic platform driver, Hans J. Koch, (Tue May 20, 2:08 pm)
Re: [PATCH] UIO: generic platform driver, Uwe , (Sun May 25, 10:58 pm)
Re: [PATCH] UIO: generic platform driver, Greg KH, (Sun May 25, 11:02 pm)
Re: [PATCH] UIO: generic platform driver, Uwe , (Fri May 30, 2:16 am)
Re: [PATCH] UIO: generic platform driver, Greg KH, (Fri May 30, 9:35 am)
Re: [PATCH] UIO: generic platform driver, Uwe , (Tue Jun 3, 12:21 am)
Re: [PATCH] UIO: generic platform driver, Hans J. Koch, (Tue Jun 3, 2:24 am)