Re: [PATCH net-next] mlxsw: spectrum_router: Use struct_size() in kzalloc()

2019-02-08 Thread David Miller
From: "Gustavo A. R. Silva" Date: Thu, 7 Feb 2019 21:42:41 -0600 > One of the more common cases of allocation size calculations is finding > the size of a structure that has a zero-sized array at the end, along > with memory for some number of elements for that array. For example: > > struct foo

Re: [PATCH net-next] mlxsw: spectrum_router: Use struct_size() in kzalloc()

2019-02-07 Thread Jiri Pirko
Fri, Feb 08, 2019 at 04:42:41AM CET, gust...@embeddedor.com wrote: >One of the more common cases of allocation size calculations is finding >the size of a structure that has a zero-sized array at the end, along >with memory for some number of elements for that array. For example: > >struct foo { >

[PATCH net-next] mlxsw: spectrum_router: Use struct_size() in kzalloc()

2019-02-07 Thread Gustavo A. R. Silva
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; struct boo entry[]; }; size = sizeof(struct foo) + cou