LZO: Further cleanup of the kernel LZO library headers
PATCH 1/1 LZO: Further cleanup of the kernel LZO library headers
A further cleanup of the kernel LZO library headers which untangles and removes ~400 lines of defines. This doesn't change the core minilzo code so diffability is maintained.
Signed-off-by Richard Purdie <[email protected]>
--- lib/lzo/lzoconf.h | 96 +----------- lib/lzo/lzodefs.h | 412 +++++++++--------------------------------------------- lib/lzo/minilzo.c | 53 ------ 3 files changed, 88 insertions(+), 473 deletions(-)
As an aside, diffing minilzo.c with its userspace counterpart:
minilzo.c | 2158 -------------------------------------------------------------- 1 file changed, 29 insertions(+), 2129 deletions(-)
lib/lzo/lzoconf.h +13 -83
@@ -29,86 +29,38 @@*/ -#ifndef __LZOCONF_H_INCLUDED -#define __LZOCONF_H_INCLUDED - -#define LZO_VERSION 0x2020#define LZO_VERSION_STRING "2.02"#define LZO_VERSION_DATE "Oct 17 2005"#define USHRT_MAX 0xffff -#define LZO_EXTERN (t) t#include "lzodefs.h" - -/*********************************************************************** -// some core defines -************************************************************************/ - -#if !defined(LZO_UINT32_C ) -# if (UINT_MAX < LZO_0xffffffffL) -# define LZO_UINT32_C (c) c ## UL -# else -# define LZO_UINT32_C (c) ((c) + 0U) -# endif -#endif - -/* memory checkers */ -#if !defined(__LZO_CHECKER) -# if defined(__BOUNDS_CHECKING_ON) -# define __LZO_CHECKER 1 -# elif defined(__CHECKER__) -# define __LZO_CHECKER 1 -# elif defined(__INSURE__) -# define __LZO_CHECKER 1 -# elif defined(__PURIFY__) -# define __LZO_CHECKER 1 -# endif -#endif - - -/*********************************************************************** -// integral and pointer types -************************************************************************/ -/* lzo_uint should match size_t */ -#if !defined(LZO_UINT_MAX ) -# if defined(LZO_ABI_IP32L64 )/* MIPS R5900 */ +#if defined(LZO_ABI_IP32L64 )/* MIPS R5900 */ typedef unsigned int lzo_uint ;typedef int lzo_int ; -# define LZO_UINT_MAX UINT_MAX -# define LZO_INT_MAX INT_MAX -# define LZO_INT_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) +# define LZO_UINT_MAX UINT_MAX +#elif (ULONG_MAX >= LZO_0xffffffffL)typedef unsigned long lzo_uint ;typedef long lzo_int ; -# define LZO_UINT_MAX ULONG_MAX -# define LZO_INT_MAX LONG_MAX -# define LZO_INT_MIN LONG_MIN -# else -# error "lzo_uint" -# endif +# define LZO_UINT_MAX ULONG_MAX +#else +# error "lzo_uint"#endif /* Integral types with 32 bits or more. */ -#if !defined(LZO_UINT32_MAX ) -# if (UINT_MAX >= LZO_0xffffffffL) +#if (UINT_MAX >= LZO_0xffffffffL)typedef unsigned int lzo_uint32 ;typedef int lzo_int32 ; -# define LZO_UINT32_MAX UINT_MAX -# define LZO_INT32_MAX INT_MAX -# define LZO_INT32_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) +# define LZO_UINT32_MAX UINT_MAX +#elif (ULONG_MAX >= LZO_0xffffffffL)typedef unsigned long lzo_uint32 ;typedef long lzo_int32 ; -# define LZO_UINT32_MAX ULONG_MAX -# define LZO_INT32_MAX LONG_MAX -# define LZO_INT32_MIN LONG_MIN -# else -# error "lzo_uint32" -# endif +# define LZO_UINT32_MAX ULONG_MAX +#else +# error "lzo_uint32"#endif /* The larger type of lzo_uint and lzo_uint32. */
@@ -131,31 +83,10 @@#define lzo_xintp lzo_xint *#define lzo_voidpp lzo_voidp *#define lzo_bytepp lzo_bytep * -/* deprecated - use `lzo_bytep' instead of `lzo_byte *' */ -#define lzo_byte unsigned char - -typedef int lzo_bool ; - - -/*********************************************************************** -// function types -************************************************************************/ -/* name mangling */ -#define __LZO_EXTERN_C extern -/* __cdecl calling convention for public C and assembly functions */ -#if !defined(LZO_PUBLIC ) -# define LZO_PUBLIC (_rettype) _rettype -#endif -#if !defined(LZO_EXTERN ) -# define LZO_EXTERN (_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) -#endif -#if !defined(LZO_PRIVATE ) -# define LZO_PRIVATE (_rettype) static _rettype -#endif +#define LZO_PUBLIC (_rettype) _rettype -/* function types */ typedef int (*lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len,
@@ -183,4 +114,3 @@ typedef intlzo_voidp wrkmem, const lzo_bytep dict, lzo_uint dict_len ); -#endif /* already included */
lib/lzo/lzodefs.h +71 -341
495 lines not on this page · raw message
lib/lzo/minilzo.c +4 -49
104 lines not on this page · raw message
Quoted 3 lines · Richard Purdie
A further cleanup of the kernel LZO library headers which untangles and removes ~400 lines of defines. This doesn't change the core minilzo code so diffability is maintained.
You should just throw away that. Guptas implementation is much cleaner, work with that. Putting a few bound checks into Guptas version will solve crashes and overruns by returning an error.
Signature · 3 lines
Heikki Orsila Barbie's law: [email protected] "Math is hard, let's go shopping!" http://www.iki.fi/shd