[PATCH 1/4] iio: light: Add a blank line after declarations

Joe Perches joe at perches.com
Mon Dec 15 17:48:44 EET 2014


On Mon, 2014-12-15 at 17:18 +0200, Daniel Baluta wrote:
> On Fri, Dec 12, 2014 at 4:31 PM, Roberta Dobrescu <roberta.dobrescu at gmail.com> wrote:
> > This patch fixes the following checkpatch.pl warning:
> > WARNING: Missing a blank line after declarations
[]
> > diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
[]
> > @@ -99,8 +99,8 @@ static int adjd_s311_req_data(struct iio_dev *indio_dev)
> >  static int adjd_s311_read_data(struct iio_dev *indio_dev, u8 reg, int *val)
> >  {
> >         struct adjd_s311_data *data = iio_priv(indio_dev);
> > -
> >         int ret = adjd_s311_req_data(indio_dev);
> > +
> >         if (ret < 0)
> >                 return ret;
> 
> I'm not sure about this. I would definitely prefer checking the
> return code immediately after the function call.
> 
> Better, would be something like this:
> 
> diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
[]
> @@ -99,8 +99,9 @@ static int adjd_s311_req_data(struct iio_dev *indio_dev)
>  static int adjd_s311_read_data(struct iio_dev *indio_dev, u8 reg, int *val)
>  {
>         struct adjd_s311_data *data = iio_priv(indio_dev);
> +       int ret;
> 
> -       int ret = adjd_s311_req_data(indio_dev);
> +       ret = adjd_s311_req_data(indio_dev);
>         if (ret < 0)
>                 return ret;
> 
> Adding Joe for comments.

Hello Daniel.

I am not the arbiter of taste and it's not my code.

Jonathan Cameron (cc'd) is the nominal maintainer here.

fyi: my preference is to initialize local variables
in a definitions block, but not necessarily always.

int foo(void)
{
	int i;
	type bar = baz();
	int rtn = 0;

	for (i = 0; i < bar; i++)
		rtn += do_something();

	return rtn;
}

I'm not a big proponent of the forced blank line
between definitions and code.

Most of the time it's probably reasonable, but for
very short code blocks, it seems unnecessary.

And when there's an initialization followed by an
immediate test, the blank line seems unnecessary
to me.

Maybe then it's better to set the variable on a
separate line.

Dunno and I don't care much either way.

cheers, Joe



More information about the firefly mailing list