[PATCH] Documentation/zh_CN: update Chinese version CodingStyle

From: Andy Deng
Date: Sun May 29 2016 - 11:47:38 EST


Chinese version CodingStyle is a little outdate, it should be updated.

This patch sync with the latest CodingStyle of all changes,
new chapters (chapter 19 and chapter 20) have been translated.

Signed-off-by: Andy Deng <theandy.deng@xxxxxxxxx>
---
Documentation/zh_CN/CodingStyle | 581 ++++++++++++++++++++++++----------------
1 file changed, 350 insertions(+), 231 deletions(-)

diff --git a/Documentation/zh_CN/CodingStyle b/Documentation/zh_CN/CodingStyle
index 654afd7..bbb9d6a 100644
--- a/Documentation/zh_CN/CodingStyle
+++ b/Documentation/zh_CN/CodingStyle
@@ -24,34 +24,33 @@ Documentation/CodingStyleçäæçè

Linuxåæäçéæ

-èæääçççææïæèälinuxåæçééäçéæãäçéææåäèåçïèäæ
-äææææçèçååçäääïäèèéæèèçææåéèçæçäçæéåçéæï
-åäæäåæçååæåääçäèéåèäéæãèååäçæèåèèääæææèç
-éæã
+èæääçççææïæèä linux åæçééäçéæãäçéææåäèåçïèäæ
+äæææèåçèçååçäääïäèååæååäääæéåééåçååéæïæä
+åæåçååæäääæèççæåãèïååäçæïèåèèääèéçäçéæã

-éåïæåèäæåääGNUäçèèïçåäèèåãçäåïèæääåæéåèåæ
-æäçåäã
+éåïæåèäæåää GNU äçèèïçåäèèãçäåïèæääåæéåèåææä
+çåäã

äçææïçåæäååï


- çäçïçè
+ çäçïçè

-åèçæ8äåçïæäçèäæ8äåçãæäåçèåèååçèåä4ïäè2ïäåç
-æïèåäçåäåèåååççååää3ã
+åèçæ 8 äåçïæäçèäæ 8 äåçãæäåçèåèååçèåä 4ïçè 2ïï
+äåçæïèåäçåäåèåååççååää 3ã

ççïçèçåéæäååäææçåäääæååèæääåãååæåäççäçåå
-èççä20åæäåïäåäåçåäçççèäääæåæåèçèã
+èççä 20 åæäåïäåäåçåäçççèäääæåæåèçèã

-çåïæäääææ8äåçççèäääçååèçåçåèïå80äåççççååä
-ååéèèæçäçãèäééççææïåæäéè3çääççèïäççäçæåä
+çåïæäääææ 8 äåçççèäääçååèçåçåèïå 80 äåççççååä
+ååéèèæçäçãèäééççææïåæäéè 3 çääççèïäççäçæåä
çäçåçæééäïåèäæäççåã

-çèèäï8äåçççèåäèäçæåæéèïèæääååæåäçåæåååæç
+çèèäï8 äåçççèåäèäçæåæéèïèæääååæåäçåæåååæç
æååäçäèåãçåèäèåã

-åswitchèåäæéåççèçééçæåæèâswitchâåäåäåçâcaseâæçåéäå
-äåïèäèâäæçèââcaseâæçãæåï
+å switch èåäæéåççèçééçæåæè âswitchâ åäåäåç âcaseâ æç
+åéäåäåïèäè âäæçèâ âcaseâ æçãæåï

switch (suffix) {
case 'G':
@@ -70,7 +69,6 @@ Documentation/CodingStyleçäæçè
break;
}

-
äèæåäèåæåäèéïééäæäääèèéèï

if (condition) do_this;
@@ -79,7 +77,7 @@ Documentation/CodingStyleçäæçè
ääèåäèéæåäèåèåãåæäçéæèççåãåæéååèåèåäèèçè
èåã

-éäæéãææåKconfigäåïäèäççææçèïåéçäåæäåïæææääã
+éäæéãææå Kconfig äåïäèäççææçèïåéçäåæäåïæææääã

éçääåççèåïäèåèåççæã

@@ -88,27 +86,18 @@ Documentation/CodingStyleçäæçè

äçéæçæäååääçååäççååæçæäççåèæååçææã

-æäèçéåçéåæ80åïæäåçåèæéåèäæäã
+æäèçéåçéåæ 80 åïæäåçåèæéåèäæäã

-éä80åçèåèæææææäççæãæäçæèææçäåæçèåïèäæççäç
-äææçéåãåæçèåäéçäæåéåæåèçåæåãéåçääèæææèçç
-åçäãåäçäåæèè80ååäåååæéåèæåäääéèäæçæåã
-
-void fun(int a, int b, int c)
-{
- if (condition)
- printk(KERN_WARNING "Warning this is a long printk with "
- "3 parameters a: %u b: %u "
- "c: %u \n", a, b, c);
- else
- next_statement;
-}
+éä 80 åçèåèæææææäççæãééèè 80 åèæèåååèæïåäääéè
+äæãåçæèææçäæçæïåææéåãèåæéçäæçåéåæåèçåæåã
+çèïçåäèææåçæåèçåçäïäå printk äæïåäèååèææ grep èä
+äæã

çäçïåæååçæçæç

Cèèéæäååääåèééæåæåçæçãåçèååäåïéææåçæçæçç
-çåææååææäçååïäèééçæåïååKernighanåRitchieåççæäçïæ
-æèååæåæåèåïèæçæåæåæåèéïæäï
+çåææååææäçååïäèééçæåïåå Kernighan å Ritchie åççæäçï
+ææèååæåæåèåïèæçæåæåæåèéïæäï

if (x is true) {
we do y
@@ -134,12 +123,12 @@ Cèèéæäååääåèééæåæåçæçãåçèåå
body of function
}

-åäççåçåèäææèäääèææââåââääèçïäèæææçååçäéçéï
-aïK&Ræ_æçç_ïåäïbïK&RææççãæåïäçææåæéæçæçïåCèèä
-ïåææäèååçïã
+åäççåçåèäææèäääèææââåââääèçïäèæææçååçäéçé
+(a) K&R æ _æçç_ïåä (b) K&R ææççãæåïäçææåæéæçæçïC
+åææäèååçïã

-ææçæåæåçèåæäèïééååéèçåääèåçåäéåïäåædoèåäç
-âwhileâæèifèåäçâelseâïåèæï
+ææçæåæåçèåæäèïééååéèçåääèåçåäéåïäåæ do èåäç
+âwhileâ æè if èåäç âelseâïåèæï

do {
body of do-loop
@@ -158,41 +147,50 @@ aïK&Ræ_æçç_ïåäïbïK&Rææççãæåïäçææå
ççïK&Rã

äèææèçåæåçæçæåäèäçïæèåäåççïèçæéæååïåæäåå
-èæãåæïçääçååäçæèæäååçèæïææ25èçççååïïäåäææ
+èæãåæïçääçååäçæèæäååçèæïææ 25 èçççååïïäåäææ
åççèææçæéã

ååæääåççèåçæåïäçåäåèçåæåã

-if (condition)
- action();
+ if (condition)
+ action();
+

+
+ if (condition)
+ do_this();
+ else
+ do_that();

-èçäéçäæèäæäæäèåçääåæçåçèåãèæéèåääåæééäçå
-æåã
+èåäéçäåæääæäåææåèåçæåïèæææåæéèäçåæåï

-if (condition) {
- do_this();
- do_that();
-} else {
- otherwise();
-}
+ if (condition) {
+ do_this();
+ do_that();
+ } else {
+ otherwise();
+ }

3.1ïçæ

-Linuxåæççæäçæåïäèïååäåæçäåæèæåéåãïååæïåéåå
-èåääçæãååææçäåæsizeofãtypeofãalignofå__attribute__ïèäåéå
-æäçåäçèææååæïåäåLinuxéäååäéåæåèäçïåçåCèèéèæ
-çåæåäæåéçïååâstruct fileinfo infoâåæèåçâsizeof infoâïã
+Linux åæççæäçæåïäèïååäåæçäåæèæåéåãïååæïåéåå
+èåääçæãååææçäåæ sizeofãtypeofãalignof å __attribute__ïèä
+åéåæäçåäçèææååæïåäå Linux éäååäéåæåèäçïåçå C é
+èæçåæåäæåéçïåå âstruct fileinfo infoâ åæèåç âsizeof infoâïã

æäåèäåéåäåæääçæï
+
if, switch, case, for, do, while
-äæäèåsizeofãtypeofãalignofæè__attribute__èäåéåäåæçæãäåï
+
+äæäèå sizeofãtypeofãalignof æè __attribute__ èäåéåäåæçæãäåï
+
s = sizeof(struct file);

äèååæåéçèèåääåçæãèæääåäï

s = sizeof( struct file );

-ååææéçåæèèåæéçåçåææïâ*âçééäçæåæääéèåéåæèå
+ååææéçåæèèåæéçåçåææïâ*â çééäçæåæääéèåéåæèå
æåïèäæéèçååãäåï

char *linux_banner;
@@ -204,15 +202,18 @@ Linuxåæççæäçæåïäèïååäåæçäåæèæå
= + - < > * / % | & ^ <= >= == != ? :

äæäåæäçåäèåçæï
+
& * + - ~ ! sizeof typeof alignof __attribute__ defined

åçèååèåäåæäçåäåçæï
+
++ --

åçèååèåäåæäçåäåçæï
+
++ --

-â.âåâ->âçæäæåæäçååäåçæã
+â.â å â->â çæäæåæäçååäåçæã

äèåèåçççãæäåäèåçèççèåäåæèçèéååééçççïçåä
ååäçæåéäèèåäçãäèååäæåææåéäèèåäçïæäçèååä
@@ -225,23 +226,23 @@ Linuxåæççæäçæåïäèïååäåæçäåæèæå

çåçïåå

-CæääçæçèèïäçååäåèèæãåModula-2åPascalçååäåïCçååää
-ççäThisVariableIsATemporaryCounterèæåäçååãCçååäçéäåéäâtmpâ
-ïèæåèæäæåæïèäèåäääåéäçèã
+Cæääçæçèèïäçååäåèèæãå Modula-2 å Pascal çååäåïC çåå
+ääççä ThisVariableIsATemporaryCounter èæåäçååãC çååäçéäåé
+ä âtmpâïèæåèæäæåæïèäèåäääåéäçèã

äèïèçæçåååçååæäæåäççïäæåååéèæéèääåæèæçåå
-ãçääåååæäâfooâæääéäéæçéèã
+ãçääåååæä âfooâ æääéäéæçéèã

åååéïåæåäçæéèåäçæååçåïéèæääåæèæçååïååååå
-æãåæäæääåäèçæåçææéçåæïäåèååâcount_active_users()âæè
-çäçååïääåèååâcntuser()âã
+æãåæäæääåäèçæåçææéçåæïäåèåå âcount_active_users()â
+æèçäçååïääåèåå âcntuser()âã

ååæåäåååæçåïæèçåçåååæïæèååäééââçèåçééäçåè
äèåææéäçåïèæååèæçåååçæäãéæåèææåéåæééççåã

æååéååèççïèäèåèèçåçåäãåæäæääéæçææåçåçèæå
-ïååèèçäâiâãååâloop_counterâåæçåïåæåææèèèçåèçèãçä
-çïâtmpâåäçæçåäæçåçäæåéã
+ïååèèçä âiâãåå âloop_counterâ åæçåïåæåææèèèçåèçèã
+çäçïâtmpâ åäçæçåäæçåçäæåéã

åæäæææääçæååéåïäåéååääééäïåååæåéèåèåèçåç
ãèççåçïåæïã
@@ -249,9 +250,9 @@ CæääçæçèèïäçååäåèèæãåModula-2åPascal

çäçïTypedef

-äèäççäâvps_tâäççäèã
+äèäççä âvps_tâ äççäèã

-åçæäåæéäçtypedefæääéèãåäåäçéçåï
+åçæäåæéäç typedef æääéèãåäåäçéçåï

vps_t a;

@@ -261,91 +262,91 @@ CæääçæçèèïäçååäåèèæãåModula-2åPascal

struct virtual_container *a;

-äåçéâaâæäääã
+äåçé âaâ æäääã

-ååäèätypedefâèæéåèæâãåéäæèæçãåäååäåæåäæçï
+ååäèä typedef âèæéåèæâãåéäæèæçãåäååäåæåäæçï

- (a) ååäéæçåèïèçæåäèäåäçtypedefæéèèäåèåéäæääïã
+ (a) ååäéæçåèïèçæåäèäåäç typedef æéèèäåèåéäæääïã

- äåïâpte_tâçäéæåèïäåèçåéçèéåææèéåäã
+ äåïâpte_tâ çäéæåèïäåèçåéçèéåææèéåäã

- ææïäéææåâèéåæâæèæäåçãæääçpte_tççåçåååäççæ
+ ææïäéææåâèéåæâæèæäåçãæääç pte_t ççåçåååäççæ
ååææääåççåèéäæã

- (b) ææçææçåïåæïèåæèååäååæéååæâintâèæâlongâçææã
+ (b) ææçææçåïåæïèåæèååäååæéååæ âintâ èæ âlongâ çææã

- u8/u16/u32æååææééçtypedefïäèåäæçåçå(d)èäæèéã
+ u8/u16/u32 æååææééç typedefïäèåäæçåçå (d) èäæèéã

- åæææïèèæåïåéäåæåãåææäåéæâunsigned longâïéäææåè
+ åæææïèèæåïåéäåæåãåææäåéæ âunsigned longâïéäææåè

typedef unsigned long myflags_t;

- äèåææääæççååïæåååæçæåäåèäæääâunsigned intâèå
- åäæåäåèäâunsigned longâïéäåäèçèïèååäçtypedefã
+ äèåææääæççååïæåååæçæåäåèäæää âunsigned intâ èå
+ åäæåäåèä âunsigned longâïéäåäèçèïèååäç typedefã

(c) åääçsparseæåéçååääæçåæåçåææçæåã

(d) åæåC99çåçåççåïåæääåçæåäã

- èçèççåèçæéåæçæåçåæåâuint32_tâäéèèååæéïåææä
+ èçèççåèçæéåæçæåçåæå âuint32_tâ äéèèååæéïåææä
ääçæçäçåäã

- åæïLinuxçæççåäæåçåçâu8/u16/u32/u64âçåååäçæçåçåæè
+ åæïLinux çæççåäæåçåç âu8/u16/u32/u64â çåååäçæçåçåæè
åèçââåçåäèåçæäçäïåääæååèæèäççã

åçèåçäçäæäçåéçåæäçæïäåèéåéääçäåçååçéæã

(e) åäåçæçéååäçççåã

- åæäçæçéåèççæäéïæääèèæC99çåèääèçäéæåçâu32â
- çåãåæïæäåäçæçéåäçææçæäääç__u32åçäççåã
+ åæäçæçéåèççæäéïæääèèæC99çåèääèçäéæåç âu32â
+ çåãåæïæäåäçæçéåäçææçæäääç __u32 åçäççåã

-åèèæåäçæåïäèåæçèåææèäèäçtypedefïééäåäæççåçä
+åèèæåäçæåïäèåæçèåææèäèäç typedefïééäåäæççåçä
èæäèåäçääã

æçæèïåæääæéæèääçæäéçåçåäåççèçæèéåïéäåäåä
-åèæäätypedefã
+åèæää typedefã


çåçïåæ

åæåèççèæäïåäååæäääæãåæåèåääåæèäåæçåïæäéç
-éISO/ANSIååååæ80x24ïïååäääæïèäæåååã
+é ISO/ANSI ååååæ 80x24ïïååäääæïèäæåååã

ääåæçæåéåæåèåæçåæååçèçææåæçãæäïåæäæääçèä
-åçåçåæääåéïäæçåïçcaseèåçåæïèääéèåæäcaseéåååå
-åçäæïèæçåæåçåéïääæåäçã
+åçåçåæääåéïäæçåïç case èåçåæïèääéèåæä case éå
+ååååçäæïèæçåæåçåéïääæåäçã

äèïåæäæääåæçåæïèääæçääååäæåéçéääåçåçåèçè
æäææèäåæçççïäåèäæçéååéæåçéåéåãäçèååæïåää
åäåæèæçååïåæäèååäçæèåéèçèïåäèçèååèåäïèæç
ææååäæäåääåæåæçææèåãï

-åæçååääèéæåææååéçæéãææéäåèè5ï10äïååäçåæåæ
+åæçååääèéæåææååéçæéãææéäåèè 5ï10 äïååäçåæåæ
ééäãéæèèäääçåæïæååæææåçåæãäçåèäèåäèæçåæè
-è7ääåçäçïåæåååçèïåäçæäãåääèéèäïääåèäèäæä2
-äææååèçäæã
+è 7 ääåçäçïåæåååçèïåäçæäãåääèéèäïääåèäèäæä
+2 äææååèçäæã

-åææäéïäççèéåäåçåæãåæèåæéèèååïåçEXPORT*ååèçè
+åææäéïäççèéåäåçåæãåæèåæéèèååïåç EXPORT* ååèçè
ååççæåæåääãæåï

-int system_is_up(void)
-{
- return system_state == SYSTEM_RUNNING;
-}
-EXPORT_SYMBOL(system_is_up);
+ int system_is_up(void)
+ {
+ return system_state == SYSTEM_RUNNING;
+ }
+ EXPORT_SYMBOL(system_is_up);

-ååæååäïåååæåååäçææçåãèçCèèéææèæçèæïåLinuxéè
+ååæååäïåååæåååäçææçåãèçCèèéææèæçèæïå Linux éè
ææåçåæïåäèæåäåçåççèèæäæåçæäåçäæã


çäçïéäçåæéåéå

-èçèæääåçåçèæïäægotoèåççäçèæçåèçèåæäçïåäååæ
+èçèæääåçåçèæïäæ goto èåççäçèæçåèçèåæäçïåäååæ
ææäèèæäã

-åääåæäåääçéååäéèåääéççæçåäçæåïgotoçåååæçåæ
-äã
+åääåæäåääçéåïåäéèåääçäæççåèæäæïgoto èåååæääã
+åæåäéèæçæäïéäçæ return ååã

ççæï

@@ -354,26 +355,37 @@ EXPORT_SYMBOL(system_is_up);
- åäéåçääææåèæææäåççéåçèåèçéè
- åèäçèåçåäïæéåéåääç;)

-int fun(int a)
-{
- int result = 0;
- char *buffer = kmalloc(SIZE);
-
- if (buffer == NULL)
- return -ENOMEM;
-
- if (condition1) {
- while (loop1) {
- ...
+ int fun(int a)
+ {
+ int result = 0;
+ char *buffer;
+
+ buffer = kmalloc(SIZE, GFP_KERNEL);
+ if (!buffer)
+ return -ENOMEM;
+
+ if (condition1) {
+ while (loop1) {
+ ...
+ }
+ result = 1;
+ goto out_buffer;
}
- result = 1;
- goto out;
+ ...
+ out_buffer:
+ kfree(buffer);
+ return result;
}
- ...
-out:
- kfree(buffer);
- return result;
-}
+
+ääéèææçåèéèæâää err éèâïååèæï
+
+ err:
+ kfree(foo->bar);
+ kfree(foo);
+ return ret;
+
+èæäççéèæïåæäéåèåä âfooâ æ NULLãéåæåäïéèæååçæää
+éèæç âerr_bar:â å âerr_foo:â æäåèäéèã

çåçïæé

@@ -386,10 +398,10 @@ out:
åååãäåèåçïæææéæååæçåéïåèääååäääïäåäåäååè
ääæçååã

-åæéåæAPIåææïèäçkernel-docæåãèç
-Documentation/kernel-doc-nano-HOWTO.txtåscripts/kernel-docäèåèçäæã
+åæéåæAPIåææïèäç kernel-doc æåãèç
+Documentation/kernel-doc-nano-HOWTO.txtåscripts/kernel-doc äèåèçäæã

-LinuxçæééææC89â/* ... */âéæãäèäçC99éæâ// ...âæéã
+Linuxçæééææ C89 â/* ... */â éæãäèäç C99 éæ â// ...â æéã

éïåèïçééæééææï

@@ -402,6 +414,15 @@ LinuxçæééææC89â/* ... */âéæãäèäçC99éæâ// ...
* with beginning and ending almost-blank lines.
*/

+åäå net/ å drivers/net/ çæäïééçéïåèïæééææääåã
+
+ /* The preferred comment style for files in net/ and drivers/net
+ * looks like this.
+ *
+ * It is nearly the same as the generally preferred comment style,
+ * but there is no initial almost-blank line.
+ */
+
æéææäæåéèçïäçæåæçåèæèççåãääæäåçèäçïæäèåå
åæääææïäèäçéåæäæåæåäææïãèæäåæçéæäæäææåäæ
åæéæèéåäççéäã
@@ -409,49 +430,63 @@ LinuxçæééææC89â/* ... */âéæãäèäçC99éæâ// ...

çäçïäåçæäæåçä

-èæääïæäéæèæãåèäçäçäåéæéUnixçæååçåèäâGNU emacsâè
-èååäæååCæäçïèäääææåäïçåæèæïäèåæäççéèååæä
-æèççåçèïåéäïçèæéææçèèåââææäçååGNU emacséæåæèä
-äåéåääåçåïïèæïèåèInfinite Monkey Theoremï
-
-æääèäæåGNU emacsïèäæååèåäçæåççèåãèéçåääææïäå
-äæäéèæçèåäç.emacsæäéã
-
-(defun linux-c-mode ()
- "C mode with adjusted defaults for use with the Linux kernel."
- (interactive)
- (c-mode)
- (c-set-style "K&R")
- (setq tab-width 8)
- (setq indent-tabs-mode t)
- (setq c-basic-offset 8))
-
-èæååääM-x linux-c-modeåäãåähackääæåçæåïåæäæåçä
--*- linux-c -*-æååäèçæääçïèäæååäèèåèçãåæäåæåääæ
-/usr/src/linuxéçæäæéæèèåæålinux-c-modeçèïääåèéèæå
-
-(setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode)
- auto-mode-alist))
-
-åäç.emacsæäéã
-
-äèåçäåèèemacsæççæååäçåèäïäåäæåçäååääåïèåäçâ
-indentâã
-
-äèïGNU indentäæåGNU emacsäææééçèåïæääéèçåääåäééãä
-èïèèäçåççïåäåçæGNU indentçäèäèåK&RçæåæïGNUçäåäæå
-äïääåæåèäééäèäéçèåäïïæääåèçindentæåééâ-kr -i8â
-ïäèâK&Rï8äåççèâïïæèäçâscripts/Lindentâïèæååääææéçæå
+èæääïæäéæèæãåèäçäçäåéæé Unix çæååçåèä âGNU emacsâ è
+èååäæåå C æäçïèäääææåäïçåæèæïäèåæäççéèååæä
+æèççåçèïåéäïçèæéææçèèåââææäçåå GNU emacs éæåæèä
+äåéåääåçåïïèæïèåè Infinite Monkey Theoremï
+
+æääèäæå GNU emacsïèäæååèåäçæåççèåãèéçåääææïäå
+äæäéèæçèåäç .emacs æäéã
+
+(defun c-lineup-arglist-tabs-only (ignored)
+ "Line up argument lists by tabs, not spaces"
+ (let* ((anchor (c-langelem-pos c-syntactic-element))
+ (column (c-langelem-2nd-pos c-syntactic-element))
+ (offset (- (1+ column) anchor))
+ (steps (floor offset c-basic-offset)))
+ (* (max steps 1)
+ c-basic-offset)))
+
+(add-hook 'c-mode-common-hook
+ (lambda ()
+ ;; Add kernel style
+ (c-add-style
+ "linux-tabs-only"
+ '("linux" (c-offsets-alist
+ (arglist-cont-nonempty
+ c-lineup-gcc-asm-reg
+ c-lineup-arglist-tabs-only))))))
+
+(add-hook 'c-mode-hook
+ (lambda ()
+ (let ((filename (buffer-file-name)))
+ ;; Enable kernel mode for the appropriate files
+ (when (and filename
+ (string-match (expand-file-name "~/src/linux-trees")
+ filename))
+ (setq indent-tabs-mode t)
+ (setq show-trailing-whitespace t)
+ (c-set-style "linux-tabs-only")))))
+
+èäè emacs å ~/src/linux-trees çåäç C ææäèåæåçåæäçéæã
+
+äèåçäåèè emacs æççæååäçåèäïäåäæåçäååääåïèåäç
+âindentâã
+
+äèïGNU indent äæå GNU emacs äææééçèåïæääéèçåääåäééãä
+èïèèäçåççïåäåçæ GNU indent çäèäèå K&R çæåæïGNU çäåäæ
+åäïääåæåèäééäèäéçèåäïïæääåèç indent æåéé â-kr -i8â
+ïäè âK&Rï8 äåççèâïïæèäç âscripts/Lindentâïèæååääææéçæå
çèæäçã

-âindentâæååééïçåæéææååæéçæåïäåèéèçääåçæåéãäè
-èäïâindentâäèäæåçççäæã
+âindentâ æååééïçåæéææååæéçæåïäåèéèçääåçæåéãäè
+èäïâindentâ äèäæåçççäæã


- çåçïKconfigéçæä
+ çåçïKconfig éçæä

-åäéåæçæçææKconfig*éçæäæèïåäçèæåäCäççæææäåãçæ
-åâconfigâåääéçèçèääåèçïååäæåååçè2äçæãæåï
+åäéåæçæçææ Kconfig* éçæäæèïåäçèæåä C äççæææäåãçæ
+å âconfigâ åääéçèçèääåèçïååäæåååçè 2 äçæãæåï

config AUDIT
bool "Auditing support"
@@ -470,7 +505,7 @@ config ADFS_FS_RW
depends on ADFS_FS
...

-èæçéçæäçåæææïèçDocumentation/kbuild/kconfig-language.txtã
+èæçéçæäçåæææïèç Documentation/kbuild/kconfig-language.txtã


çåäçïææçæ
@@ -489,11 +524,11 @@ config ADFS_FS_RW
ååææçæåéäæ2çåçèæïåäéåæäåâçâççæãåçèæåçèåçç
æçæéïæååçèæååèéæïååèæååäã

-èçâåçåçèæâçäååäåååççïâstruct mm_structâïmm_usersåmm_countï
+èçâåçåçèæâçäååäåååççïâstruct mm_structâïmm_users å mm_countï
åæäççïâstruct super_blockâïs_countås_activeïäæåã

èäïåæåääæèççåäæåäçææçæïäæèäææçæææåçèæåïè
-éåäèåæääbugã
+éåäèåæää bugã


çåäçïåïæäåRTL
@@ -508,102 +543,128 @@ config ADFS_FS_RW

äèçïåæèåæåèåæåäèåæååæçåã

-åæåäèåçååèèåååäädo-whileäçåéï
+åæåäèåçååèèåååää do-while äçåéï

-#define macrofun(a, b, c) \
- do { \
- if (a == 5) \
- do_this(b, c); \
- } while (0)
+ #define macrofun(a, b, c) \
+ do { \
+ if (a == 5) \
+ do_this(b, c); \
+ } while (0)

äçåçæååéåçäæï

1) ååæåæççåï

-#define FOO(x) \
- do { \
- if (blah(x) < 0) \
- return -EBUGGERED; \
- } while(0)
+ #define FOO(x) \
+ do { \
+ if (blah(x) < 0) \
+ return -EBUGGERED; \
+ } while (0)

éåäåãåçèæåääåæïäèåèåèâèçâåçåæéåïäèæäèèåèé
çèæåæåã

2) äèäääååååçæååéçåï

-#define FOO(val) bar(index, val)
+ #define FOO(val) bar(index, val)

åèçèæåæääéçäèïäèåéååææèäççäæçæïèäåæåèçèæ
äçåçæååæéèã

-3) ääååçååæçåï FOO(x) = yïåææäæFOOåæääåèåæçèïèçç
+3) ääååçååæçåï FOO(x) = yïåææäæ FOO åæääåèåæçèïèçç
æåäåéäã

4) åèääåçïäçèèååäåéçååéåèèåçääååæåäåãååæç
åäèæææçééã

-#define CONSTANT 0x4000
-#define CONSTEXP (CONSTANT | 3)
+ #define CONSTANT 0x4000
+ #define CONSTEXP (CONSTANT | 3)
+
+5) ååéåäçäåæçæååéæåååçï

-cppæåååçèèåèçãGcc internalsæåäèçèèäRTLïèæïregister
+ #define FOO(x) \
+ ({ \
+ typeof(x) ret; \
+ ret = calc_ret(x); \
+ (ret); \
+ })
+
+ret ææååéçéçåå - __foo_ret æäåæäääåååçåéåçã
+
+cpp æåååçèèåèçãgcc internals æåäèçèèä RTLïèæïregister
transfer languageïïåæéçæçèèçåçååã


çåäçïæååæææ

åæååèåèæåèèåæèçãèäåææåæäæçæåïäçääåçåèãäè
-çäèèçåèæåâdontâïèèçâdo notâæèâdon'tâãäèèääæçåãæäãæ
-æäã
+çäèèçåèæå âdontâïèèç âdo notâæè âdon'tâãäèèääæçåãæäã
+ææäã

åæäæäåäååïèæïèæååïåçïçæã

-ååæåéæåæå(%d)ææäääåïåèéåèæåã
+ååæåéæåæå (%d) ææäääåïåèéåèæåã

-<linux/device.h>éæääéåæåèæåïäåèäçåäïäçääæååäæçç
-èååéåïåäèæèäæççææçåãèäåæïdev_err(), dev_warn(),
-dev_info()ççãåäéääåæäçåèåçåèçäæï<linux/kernel.h>åää
-pr_debug()åpr_info()ã
+<linux/device.h> éæääéåæåèæåïäåèäçåäïäçääæååäæçç
+èååéåïåäèæèäæççææçåãèäåæïdev_err()ïdev_warn()ï
+dev_info() ççãåäéääåæäçåèåçåèçäæï<linux/printk.h> åää
+pr_notice()ïpr_info()ïpr_warn()ïpr_err() ååäã

-åååçèèäæåäæääååçææïåäååæäåïèääæåèçééçæå
-åäæäæåçååãåDEBUGçåææèåäçæåïèääæäåèèçèèåæé
-ïäåæèïéèåïåääåèèååååïãåæääçdev_dbg()æèpr_debug()ï
-åèèåèåèäææãåååççææKconfigééæåç-DDEBUGãèæääçåçæä
-æäçVERBOSE_DEBUGææådev_vdbg()ææåéäåççDEBUGåççææääã
+åååçèèäæåäæääååçææïäæäåååïèääæåèçééæèæäæå
+çååãçèæåèèäæçåçæååæåéèèäæäåãåä pr_XXX() åæèææäå
+æåïpr_debug() åäïéèæåäåääèçèïééåää DEBUG æèåä
+CONFIG_DYNAMIC_DEBUGãåéèåææää dev_dbg()ïääçåçåæåääåçååä
+DEBUG æïäç VERBOSE_DEBUG ææå dev_vdbg()ã
+
+èååççææ Kconfig èèééæåå -DDEBUG åååç Makefile ééïååä
+æåäïçææääç #define DEBUGãåäæèèäæéèèææäæåæïäåïåæ
+åçååääèèçåç #ifdef æäïprintk(KERN_DEBUG ...) ååèäçã


çååçïåéåå

-åææäääéçäèçéçåååéåæïkmalloc()ïkzalloc()ïkcalloc()å
-vmalloc()ãèåèAPIææäèåæååäçèçäæã
+åææäääéçäèçéçåååéåæï
+kmalloc()ïkzalloc()ïkmalloc_array()ïkcalloc()ïvmalloc() å vzalloc()ã
+èåè API ææäèåæååäçèçäæã

äéçæäååçééååæèæçï

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

-ååäçäéæåäïsizeofçæäææçæäçååïèæäéäåèæïåäåèäå
-åbugãæåèæéåéçåèæåæïèååçäéçåååéåæçsizeofççæäåã
+ååäçäéæåäïsizeof çæäææçæäçååïèæäéäåèæïåäåèäå
+å bugãæåèæéåéçåèæåæïèååçäéçåååéåæç sizeof ççæäåã

-ååèæäävoidæéèååæåäçãCèèæèäèäävoidæéååäääæéçå
+ååèæää void æéèååæåäçãC èèæèäèää void æéååäääæéçå
çèææææééçã

+åéääæççééååæèæçï
+
+ p = kmalloc_array(n, sizeof(...), ...);
+
+åéääééæççééååæèæçï
+
+ p = kcalloc(n, sizeof(...), ...);
+
+äçååææåéåå n * sizeof(...) çæåïåææåèå NULLã
+

çåäçïåèåç

-æääåèçèèæåèåæægccæäçåäèäçèèæåçääééãèçäçåè
+æääåèçèèæåèåææ gcc æäçåäèäçèèæåçääééãèçäçåè
åæææåææåçïæåäääçæäåçæåïèççåäçïïäèååæåääæ
-èæãinlineåéåçèåäçääåæååïäèäæäççèèéååæãåäååæ
+èæãinline åéåçèåäçääåæååïäèäæäççèèéååæãåäååæ
äåçæåçæäééçåïèæïäççåéåææäçååææçåååçïèääå
-èpagecacheçåçååååãæèääïäæpagecacheæåäåäåèäæççååïå
-èæ5æçã5æççæéåCPUèæèååååæäã
+è pagecache çåçååååãæèääïäæpagecacheæåäåäåèäæççååï
+åèæ 5 æçã5 æççæéå CPU èæèååååæäã

-ääåæçååæåæääåææ3èääïåäèæååæåèåæãèäååçäää
+ääåæçååæåæääåææ 3 èääïåäèæååæåèåæãèäååçäää
åæïåæäçéæäåææääçèæåéïèäåäèäåéäçåçèååçèæè
-äåæäçåæçåéåäçïéäçåäçååäinlineåéåãkmalloc()åèåæå
+äåæäçåæçåéåäçïéäçåäçååä inline åéåãkmalloc() åèåæå
æääååçäåã

-ääçåäåçstaticçèäåçääæçåæåäinlineïåæääæääæåïåäæ
-æääåæèçãèçäææäèèææççïäæåéäèçæåäåääåinline gcc
-äåäèåäååèãèäåäçæåèäèæçéinlineïçæèæçäèäææinline
+ääçåäåç static çèäåçääæçåæåä inlineïåæääæääæåïåäæ
+æääåæèçãèçäææäèèææççïäæåéäèçæåäåääå inline gcc
+äåäèåäååèãèäåäçæåèäèæçé inlineïçæèæçäèäææ inline
èèçæåäåïåäååã


@@ -613,37 +674,37 @@ vmalloc()ãèåèAPIææäèåæååäçèçäæã
çääååäèçäääéèäçææï-Exxxïåèï0ïæåïæèääâæåâåååï
0ïåèïé0ïæåïã

-æåäçèäçèèæåæéäåççbugçææãåæCèèæèäæååæåååååå
-éïéäçèååèååæäåçèäéèââäèCèèäååãääéåäçèçbugïè
+æåäçèäçèèæåæéäåçç bug çææãåæ C èèæèäæååæåååååå
+éïéäçèååèååæäåçèäéèââäè C èèäååãääéåäçèç bugïè
éåäéçæäï

åæåæçååæääåäæèååæçåäïéäèäåæåèèåéèäçæ
æãåææääåæïéäåæåèèåääâæåâåååã

-æåïâadd workâæääåäïæäadd_work()åæåæåæèå0ïååèæèå-EBUSYã
-çäçïåäâPCI device presentâæääåæïæäpci_dev_present()åæåæåæå
-ääåéçèåæåèèå1ïåææäåæåèèå0ã
+æåïâadd workâ æääåäïæä add_work() åæåæåæèå 0ïååèæèå -EBUSYã
+çäçïåä âPCI device presentâ æääåæïæä pci_dev_present() åæåæåæå
+ääåéçèåæåèèå 1ïåææäåæåèèå 0ã

ææååïèæïEXPORTïçåæéåééåèäæäïææçåååæäéåèåæãç
æïstaticïåæäéèåæïäææääæèèæåã

èååæåéèççæèäæèçæåæåçæåçåæäåææäçéåãäèçïää
éèèåääæååèåäåççææèçåéãååçäåæèåæéçåæïäääç
-NULLæèERR_PTRæåææåéèã
+NULL æè ERR_PTR æåææåéèã


çåäçïäèéæåæåæå

-åæäinclude/linux/kernel.hååäääåïäåèäçåäïèäèèååääåäç
+åæä include/linux/kernel.h ååäääåïäåèäçåäïèäèèååääåäç
åçãæåïåæäéèèçääæççéåïäçèäå

- #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

çäçïåæäèèçæçæäæåçååïäç

- #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
+ #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))

-èæåäåäæççåææçmin()åmax()åïåæäéèåääçåäãäåäèåçç
+èæåäåäæççåææç min() å max() åïåæäéèåääçåäãäåäèåçç
éäåæäéèåäääääåäææççäèïåææåäçèïäåäååäçäçé
èåéæåäã

@@ -653,42 +714,100 @@ NULLæèERR_PTRæåææåéèã
æääçèååäèéåååææäéççääçææèææçéçäæãæåïemacs
èåèéèæèæèæçèï

--*- mode: c -*-
+ -*- mode: c -*-

æèèæçï

-/*
-Local Variables:
-compile-command: "gcc -DMAGIC_DEBUG_FLAG foo.c"
-End:
-*/
+ /*
+ Local Variables:
+ compile-command: "gcc -DMAGIC_DEBUG_FLAG foo.c"
+ End:
+ */

-Vimèåèéèæçæèï
+Vim èåèéèæçæèï

-/* vim:set sw=8 noet */
+ /* vim:set sw=8 noet */

äèåæäçäååääèæçååãæääéæäèåççèåéçïäçææääå
èèçåäçéçãèåææåçèåæåéççæèãääåääçääèåååçæ
åïæèäçåäåääçæçççèçååææã


+ çåäçïåèæç
+
+åçåææçäçäïääèéèåèæçæäç CPU æååååçååèãåéè
+èäåæïäèçèãçèïå C åäåæåäæïäèæçåäçåèæçãåæ
+åèïäåäåäåèç C åçäääã
+
+èèååéçäççåèæçääçæçèååæïèäæéååäåäççèãèä
+åèæçåääç C åæã
+
+åèçæçæçåæåèæå .S æääïåå C çåååäå C åæääãæç
+åæç C åååèäç âasmlinkageâã
+
+äåèéèåäçæçèåæèä volatileïæéæ GCC åæåçääåäçåå
+çéäåãääåææèæåïèçïèæåäéåäåèçäåã
+
+ååääåååææäçåäåèæçèåæïææææäçåååçäåçïååå
+åçäèïåæäåçäçåïéä \n\t çåäåïåæçèåäéååçèä
+äææäï
+
+ asm ("magic %reg1, #42\n\t"
+ "more_magic %reg2, %reg3"
+ : /* outputs */ : /* inputs */ : /* clobbers */);
+
+
+ çäåçïæäçè
+
+åèåèïåäèå .c æäééäçéåçæäïèæåèäçæééèåäéèéä
+èèãæäæææïååæäåäåæåèä .c æäääçèççæäèèåïæäç
+æäçæçæïèæïæçåïææçæææäéååèççåæïå #else æåäï
+åä .c æääææäåèçèäåæãçèåäéåçæääæèççäçïäçäè
+ççæïäéèåæåææã
+
+ååçèæäåæïèäæéååææéåèèåãèäæåääèèåæå ifdefï
+èæéåæåéèèååääåççèååæïååçæäåèåæåã
+
+åæäæääåçåéçäåèææäççåææåéïçèååèåååäääæäçï
+æèèäåää __maybe_unused èäæåååååääéåçæääãïçèïåæ
+ääåææåéæææäççïåçæåéåãï
+
+åäçäïåèçæåäïäç IS_ENABLED åæèåæä Kconfig æèä C çåå
+èèåïååæåç C æäääçåï
+
+ if (IS_ENABLED(CONFIG_SOMETHING)) {
+ ...
+ }
+
+çèåäææäåååæååïååäç #ifdef éæïååææéäçåïæäèää
+åæääèèæåéãçèïèçææäæåè C çèåæçååçäçïåææåçæç
+æïèæïçåïçååçïççïãåæïåææääæèïäçååçåççååäååï
+äåéççäç #ifdefã
+
+åääææäç #if æ #ifdef åçæåïèèåèïïå #endif åäèçåéåä
+æéïæåèæäèèåèäçãäåï
+
+ #ifdef CONFIG_SOMETHING
+ ...
+ #endif /* CONFIG_SOMETHING */
+

éå Iïåè

-The C Programming Language, çäç, äèBrian W. KernighanåDenni
-M. Ritchie. Prentice Hall, Inc., 1988. ISBN 0-13-110362-8 (èç),
-0-13-110370-9 (çç). URL: http://cm.bell-labs.com/cm/cs/cbook/
+The C Programming Language, çäç
+äèïBrian W. Kernighan å Denni M. Ritchie.
+Prentice Hall, Inc., 1988.
+ISBN 0-13-110362-8 (èç), 0-13-110370-9 (çç).

-The Practice of Programming äèBrian W. KernighanåRob Pike. Addison-Wesley,
-Inc., 1999. ISBN 0-201-61586-X. URL: http://cm.bell-labs.com/cm/cs/tpop/
+The Practice of Programming
+äèïBrian W. Kernighan å Rob Pike.
+Addison-Wesley, Inc., 1999.
+ISBN 0-201-61586-X.

-cppïgccïgcc internalsåindentçGNUæåââåK&Råææççåçéåïåéåäå
-http://www.gnu.org/manual/æå;
+GNU æå - éå K&R æååæææ - cpp, gcc, gcc internals and indent,
+éåää http://www.gnu.org/manual/ æå

WG14æCèèçåéæåååäçïURL: http://www.open-std.org/JTC1/SC22/WG14/

-Kernel CodingStyleïäègreg@xxxxxxxxxåèäOLS 2002ï
+Kernel CodingStyleïäè greg@xxxxxxxxx åèäOLS 2002ï
http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/
-
---
-æåææä2007å7æ13æã
--
2.9.0.rc0.21.g7777322