Re: [PATCH 2.6.17-rc4 1/6] Base support for kmemleak

Paul Jackson
2006-05-13T18:11:53Z

Please try to keep ifdef's out of the main kernel files.

Imagine what an unreadable mess the main kernel files
would be if every CONFIG option had its hooks wrapped
in #ifdef's.

==============================================

+#ifdef CONFIG_DEBUG_MEMLEAK
+#include <linux/memleak.h>
+#endif

should be changed to always include linux/memleak.h,
and bury the ifdefs with memleak.h so that if not
CONFIG'd, it just defines the empty stubs needed
to remove other ifdef's in the main files.

==============================================

+#ifdef CONFIG_DEBUG_MEMLEAK
+#define container_of(ptr, type, member) ({ \
+ DECLARE_MEMLEAK_OFFSET(container_of, type, member); \
+ __container_of(ptr, type, member); \
+})
+#else
+#define container_of(ptr, type, member) __container_of(ptr, type, member)
+#endif

could (not sure of this works - you'll have to experiment) become:

+#define container_of(ptr, type, member) ({ \
+ DECLARE_MEMLEAK_OFFSET(container_of, type, member); \
+ __container_of(ptr, type, member); \
+})

where DECLARE_MEMLEAK_OFFSET was an empty stub if not CONFIG'd

==============================================

+#ifdef CONFIG_DEBUG_MEMLEAK
+ memleak_init();
+#endif

becomes simply:

+ memleak_init();

where memleak_init() is an empty stuff if memleak if not CONFIG'd.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.925.600.0401