projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a482289
)
[PATCH] kcalloc(): INT_MAX -> ULONG_MAX
author
Adrian Bunk
<
[email protected]
>
Wed, 22 Mar 2006 08:08:09 +0000
(
00:08
-0800)
committer
Linus Torvalds
<
[email protected]
>
Wed, 22 Mar 2006 15:53:58 +0000
(07:53 -0800)
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 <
[email protected]
>
Signed-off-by: Andrew Morton <
[email protected]
>
Signed-off-by: Linus Torvalds <
[email protected]
>
include/linux/slab.h
patch
|
blob
|
history
diff --git
a/include/linux/slab.h
b/include/linux/slab.h
index 8cf52939d0ab676698083140e8cb80384ee6b263..38bed95dda7aaa20a348cc83bc7a87e3c70edb3f 100644
(file)
--- a/
include/linux/slab.h
+++ b/
include/linux/slab.h
@@
-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);
}