Messages in this thread | | | Date | Tue, 14 Jul 2020 15:13:24 -0500 | From | "Gustavo A. R. Silva" <> | Subject | Re: [PATCH][next] mei: Avoid the use of one-element arrays |
| |
On Tue, Jul 14, 2020 at 07:57:51PM +0000, Winkler, Tomas wrote: > > > > On Tue, Jul 14, 2020 at 05:54:32PM +0000, Winkler, Tomas wrote: > > > > > > > > There is a regular need in the kernel to provide a way to declare > > > > having a dynamically sized set of trailing elements in a structure. > > > > Kernel code should always use “flexible array members”[1] for these > > > > cases or, as in this particular case, replace the one-element array > > > > with a simple value type u8 reserved once this is just a placeholder > > > > for alignment. The older style of one-element or zero-length arrays > > should no longer be used[2]. > > > > > > > > Also, while there, use the preferred form for passing a size of a struct. > > > > The alternative form where struct name is spelled out hurts > > > > readability and introduces an opportunity for a bug when the > > > > variable type is changed but the corresponding sizeof that is passed as > > argument is not. > > > > > > > > [1] https://en.wikipedia.org/wiki/Flexible_array_member > > > > [2] https://github.com/KSPP/linux/issues/79 > > > > > > > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > > > I'm okay with the patch but in this case the description is a bit off. > > > In this case there was no intention for a flexible arrays its just a reserved > > field. > > > > > > > The reserved field is actually mentioned in the description: > > > > "... or, as in this particular case, replace the one-element array with a simple > > value type u8 reserved once this is just a placeholder for alignment." > > Right, but it looks not connected to overall context, it looks like not very clean reuse of a commit message. > I would say that this reserved[1] rather had confused the detection scripts you are using for the cleanup you are doing. > Again, I'm okay with the patch, but if you can reword the commit message it would be even more okay. >
Yep; I've come up with a more concise text for these sorts of cases:
"One-element arrays are being deprecated[1]. Replace the one-element array with a simple value type u8 reserved, once this is just a placeholder for alignment.
[1] https://github.com/KSPP/linux/issues/79"
I'll send v2 with the text above, shortly.
Thanks for the feedback. -- Gustavo
| |