diff options
| author | Tony Luck <tony.luck@intel.com> | 2005-10-20 13:41:44 -0400 |
|---|---|---|
| committer | Tony Luck <tony.luck@intel.com> | 2005-10-20 13:41:44 -0400 |
| commit | 9cec58dc138d6fcad9f447a19c8ff69f6540e667 (patch) | |
| tree | 4fe1cca94fdba8b705c87615bee06d3346f687ce /Documentation/CodingStyle | |
| parent | 17e5ad6c0ce5a970e2830d0de8bdd60a2f077d38 (diff) | |
| parent | ac9b9c667c2e1194e22ebe0a441ae1c37aaa9b90 (diff) | |
Update from upstream with manual merge of Yasunori Goto's
changes to swiotlb.c made in commit 281dd25cdc0d6903929b79183816d151ea626341
since this file has been moved from arch/ia64/lib/swiotlb.c to
lib/swiotlb.c
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'Documentation/CodingStyle')
| -rw-r--r-- | Documentation/CodingStyle | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 22e5f9036f3c..eb7db3c19227 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle | |||
| @@ -410,7 +410,26 @@ Kernel messages do not have to be terminated with a period. | |||
| 410 | Printing numbers in parentheses (%d) adds no value and should be avoided. | 410 | Printing numbers in parentheses (%d) adds no value and should be avoided. |
| 411 | 411 | ||
| 412 | 412 | ||
| 413 | Chapter 13: References | 413 | Chapter 13: Allocating memory |
| 414 | |||
| 415 | The kernel provides the following general purpose memory allocators: | ||
| 416 | kmalloc(), kzalloc(), kcalloc(), and vmalloc(). Please refer to the API | ||
| 417 | documentation for further information about them. | ||
| 418 | |||
| 419 | The preferred form for passing a size of a struct is the following: | ||
| 420 | |||
| 421 | p = kmalloc(sizeof(*p), ...); | ||
| 422 | |||
| 423 | The alternative form where struct name is spelled out hurts readability and | ||
| 424 | introduces an opportunity for a bug when the pointer variable type is changed | ||
| 425 | but the corresponding sizeof that is passed to a memory allocator is not. | ||
| 426 | |||
| 427 | Casting the return value which is a void pointer is redundant. The conversion | ||
| 428 | from void pointer to any other pointer type is guaranteed by the C programming | ||
| 429 | language. | ||
| 430 | |||
| 431 | |||
| 432 | Chapter 14: References | ||
| 414 | 433 | ||
| 415 | The C Programming Language, Second Edition | 434 | The C Programming Language, Second Edition |
| 416 | by Brian W. Kernighan and Dennis M. Ritchie. | 435 | by Brian W. Kernighan and Dennis M. Ritchie. |
