Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 9039
b: refs/heads/master
c: af4e5a2
h: refs/heads/master
i:
  9037: 0dc9d0d
  9035: ac1a291
  9031: e8c62dd
  9023: f8231b4
v: v3
  • Loading branch information
Pekka J Enberg authored and Linus Torvalds committed Sep 17, 2005
1 parent f72054f commit cab2458
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f647e08a55d2c88c4e7ab17a0a8e3fcf568fbc65
refs/heads/master: af4e5a218e18ad588d60a4f9d6f8fb5db1a32587
21 changes: 20 additions & 1 deletion trunk/Documentation/CodingStyle
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,26 @@ Kernel messages do not have to be terminated with a period.
Printing numbers in parentheses (%d) adds no value and should be avoided.


Chapter 13: References
Chapter 13: Allocating memory

The kernel provides the following general purpose memory allocators:
kmalloc(), kzalloc(), kcalloc(), and vmalloc(). Please refer to the API
documentation for further information about them.

The preferred form for passing a size of a struct is the following:

p = kmalloc(sizeof(*p), ...);

The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not.

Casting the return value which is a void pointer is redundant. The conversion
from void pointer to any other pointer type is guaranteed by the C programming
language.


Chapter 14: References

The C Programming Language, Second Edition
by Brian W. Kernighan and Dennis M. Ritchie.
Expand Down

0 comments on commit cab2458

Please sign in to comment.