The patch titled Add a new section to CodingStyle, promoting include/linux/kernel.h has been removed from the -mm tree. Its filename was add-a-new-section-to-codingstyle-promoting-include-linux-kernelh.patch This patch was dropped because it was merged into mainline or a subsystem tree ------------------------------------------------------ Subject: Add a new section to CodingStyle, promoting include/linux/kernel.h From: "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx> Add a new section to the CodingStyle file, encouraging people not to re-invent available kernel macros such as ARRAY_SIZE(), FIELD_SIZEOF(), min() and max(), among others. Signed-off-by: Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> Acked-by: Randy Dunlap <randy.dunlap@xxxxxxxxxx> Acked-by: Jan Engelhardt <jengelh@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- Documentation/CodingStyle | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff -puN Documentation/CodingStyle~add-a-new-section-to-codingstyle-promoting-include-linux-kernelh Documentation/CodingStyle --- a/Documentation/CodingStyle~add-a-new-section-to-codingstyle-promoting-include-linux-kernelh +++ a/Documentation/CodingStyle @@ -682,6 +682,24 @@ result. Typical examples would be funct NULL or the ERR_PTR mechanism to report failure. + Chapter 17: Don't re-invent the kernel macros + +The header file include/linux/kernel.h contains a number of macros that +you should use, rather than explicitly coding some variant of them yourself. +For example, if you need to calculate the length of an array, take advantage +of the macro + + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +Similarly, if you need to calculate the size of some structure member, use + + #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) + +There are also min() and max() macros that do strict type checking if you +need them. Feel free to peruse that header file to see what else is already +defined that you shouldn't reproduce in your code. + + Appendix I: References _ Patches currently in -mm which might be from rpjday@xxxxxxxxxxxxxx are origin.patch git-alsa.patch ppc-use-syslog-macro-for-the-printk-log-level.patch rewrite-unnecessary-duplicated-code-to-use-field_sizeof.patch transform-kmem_cache_allocmemset0-kmem_cache_zalloc.patch oss-replace-kmallocmemset-combos-with-kzalloc.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html