---
# System prepended metadata

title: 'Patches, Hacking, and the Community'

---

# Patches, Hacking, and the Community

# Linux Coding Style

Documentation/CodingStyle

# Indention

Tabs = 8 char in length

![](https://i.imgur.com/uod2uo9.png)

Linus覺得你function裡面如果太deep就要想辦法開始把東西抽出來做了

![](https://i.imgur.com/6SBAfjW.png)

The logic behind all this is K&R.1 Most of Linux coding style follows K&R Style,
which is the C coding style used in that famous book.


# Line Length

Lines of source code should be kept to fewer than 80 characters in length

![](https://i.imgur.com/CPsorvQ.png)

![](https://i.imgur.com/BRBXKuO.png)


# Typedefs

少用比較好
![](https://i.imgur.com/JY14hrY.png)


# Use Existing Routines

不要自己用wrapper把Linux interface包起來 ˋ__ ˊ!!!!!!

# Minimize ifdefs in the Source

不要把ifdef牽扯上執行邏輯動作
![](https://i.imgur.com/aBZzc3h.png)


# Structure Initializers

![](https://i.imgur.com/NN6FjP0.png)


自動幫你排版成linux coding style
![](https://i.imgur.com/9DqUv0Y.png)
