dect
/
linux-2.6
Archived
13
0
Fork 0

[PATCH] kcalloc(): INT_MAX -> ULONG_MAX

Since size_t has the same size as a long on all architectures, it's enough
for overflow checks to check against ULONG_MAX.

This change could allow a compiler better optimization (especially in the
n=1 case).

The practical effect seems to be positive, but quite small:

    text           data     bss      dec            hex filename
21762380        5859870 1848928 29471178        1c1b1ca vmlinux-old
21762211        5859870 1848928 29471009        1c1b121 vmlinux-patched

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Adrian Bunk 2006-03-22 00:08:09 -08:00 committed by Linus Torvalds
parent a482289d46
commit b50ec7d807
1 changed files with 1 additions and 1 deletions

View File

@ -118,7 +118,7 @@ extern void *kzalloc(size_t, gfp_t);
*/
static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
{
if (n != 0 && size > INT_MAX / n)
if (n != 0 && size > ULONG_MAX / n)
return NULL;
return kzalloc(n * size, flags);
}