Messages in this thread | | | Date | Tue, 14 Feb 2012 09:02:01 -0600 (CST) | From | Christoph Lameter <> | Subject | Re: [PATCH RFC v2] slab: introduce kmalloc_array |
| |
On Tue, 14 Feb 2012, Dan Carpenter wrote:
> SAFE_ARRAY_SIZE() would return the size if there were no overflow > and -1 on errors? We can't return zero on errors because there are > a lot of places which do zero size allocations and it's valid. It > seems ugly.
We could also catch these issues with BUG() or WARN_ON() and then return zero.
> I really think that's over thinking things. Let's just match > kcalloc() exactly except without zeroing. The BUILD_BUG_ON() thing > is an over complication as well. We haven't needed it for > kcalloc().
The best thing is to remove kcalloc and get it all cleaned up with some mechanism to safely calculate the size of an array to be allocated.
The other way will lead to naming issues and then to a multiplication of variants of the allocator interface. It makes things difficult to understand and handle.
Keep it simple by providing a function that determines the array size and handles any possible error condition.
| |