lkml.org 
[lkml]   [2005]   [Aug]   [15]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
FromDenis Vlasenko <>
SubjectRe: [-mm patch] make kcalloc() a static inline
DateMon, 15 Aug 2005 12:33:46 +0300
> > static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast flags)
> > {
> > 	if (__builtin_constant_p(n)) {
> > 		if (n != 0 && size > INT_MAX / n)
> > 			return NULL;
> > 		return kzalloc(n * size, flags);
> > 	}
> > 	return kcalloc_helper(n, size, flags);
> > }
> > 
> > void *kcalloc_helper(size_t n, size_t size, unsigned int __nocast flags)
> > {
> > 	if (n != 0 && size > INT_MAX / n)
> > 		return NULL;
> > 	return kzalloc(n * size, flags);
> > }
> 
> That's extra complexity and code duplication. How much do we shave off 
> kernel text of allyesconfig with this?
> 
> Please note that whenever the caller does proper bounds checking, GCC can 
> optimize the security check away. Therefore, in practice, we don't spread 
> around the extra operations so much, I think.

gcc can optimize that away with non-const n?! I don't think so.
--
vda

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

\
 
 \ /
  Last update: 2005-08-15 11:36    [W:0.101 / U:0.210 seconds]
©2003-2008 Jasper Spaans