Re: RFC: kernel coding style: prefer array to &array[0] ?

From: Clemens Ladisch
Date: Wed Jul 01 2015 - 07:56:02 EST


Joe Perches wrote:
> It seems most in-kernel uses are 'array' rather than '&array[0]'
>
> Most of the time, using array is simpler to read than &array[0].
>
> Exceptions exists when addresses for consecutive members are
> used like func(&array[0], &array[1]);

I use '&array[0]' when I want to get a pointer to a single object that
happens to be the first one in an array.

> Should this preference be put into checkpatch and/or CodingStyle?

How about the following low-hanging fruit?

foo(..., &array[0], ARRAY_SIZE(array), ...)


Regards,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/