From: Ian Abbott Date: Tue, 4 Dec 2007 13:11:14 +0000 (+0000) Subject: No need to define kcalloc() compatibility function for kernel 2.6.9 onwards. X-Git-Tag: v0_7_76~32 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=47d8ee685bdaa1fe2032cae2991e6fa1cb8bae86;p=comedi.git No need to define kcalloc() compatibility function for kernel 2.6.9 onwards. The kzalloc() compatibility function is still required for vanilla kernels prior to 2.6.14, but some versions of RHEL4 2.6.9 kernel (e.g. 2.6.9-42) already declare it, so use a macro to override it with our own version. --- diff --git a/include/linux/slab.h b/include/linux/slab.h index 4a1bfb3a..58734f82 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -9,7 +9,11 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) -static inline void *kzalloc(size_t size, unsigned int flags) +/* Some RHEL4 2.6.9 kernels have kzalloc. Redefine to avoid warnings + about static declaration following non-static declaration. */ +#undef kzalloc +#define kzalloc comedi_kzalloc +static inline void *comedi_kzalloc(size_t size, unsigned int flags) { void *ret = kmalloc(size, flags); if (ret) @@ -17,7 +21,11 @@ static inline void *kzalloc(size_t size, unsigned int flags) return ret; } -static inline void *kcalloc(size_t n, size_t size, unsigned int flags) +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) + +static inline void *kcalloc(size_t n, size_t size, int flags) { if (n != 0 && size > INT_MAX / n) return NULL; @@ -27,3 +35,4 @@ static inline void *kcalloc(size_t n, size_t size, unsigned int flags) #endif #endif +