aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2006-03-22 03:08:09 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-22 10:53:58 -0500
commitb50ec7d8070ae7a39fe78e65a8812bbc3ca2f7ac (patch)
tree56a30fe319a1c4356547d13896d6762df76980d7
parenta482289d46587ffcda4c85aab109fb74910d7a48 (diff)
[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>
-rw-r--r--include/linux/slab.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 8cf52939d0ab..38bed95dda7a 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -118,7 +118,7 @@ extern void *kzalloc(size_t, gfp_t);
118 */ 118 */
119static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 119static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
120{ 120{
121 if (n != 0 && size > INT_MAX / n) 121 if (n != 0 && size > ULONG_MAX / n)
122 return NULL; 122 return NULL;
123 return kzalloc(n * size, flags); 123 return kzalloc(n * size, flags);
124} 124}