linux/Documentation/CodingStyle
<<
>>
Prefs
   1
   2                Linux kernel coding style
   3
   4This is a short document describing the preferred coding style for the
   5linux kernel.  Coding style is very personal, and I won't _force_ my
   6views on anybody, but this is what goes for anything that I have to be
   7able to maintain, and I'd prefer it for most other things too.  Please
   8at least consider the points made here.
   9
  10First off, I'd suggest printing out a copy of the GNU coding standards,
  11and NOT read it.  Burn them, it's a great symbolic gesture.
  12
  13Anyway, here goes:
  14
  15
  16                Chapter 1: Indentation
  17
  18Tabs are 8 characters, and thus indentations are also 8 characters.
  19There are heretic movements that try to make indentations 4 (or even 2!)
  20characters deep, and that is akin to trying to define the value of PI to
  21be 3.
  22
  23Rationale: The whole idea behind indentation is to clearly define where
  24a block of control starts and ends.  Especially when you've been looking
  25at your screen for 20 straight hours, you'll find it a lot easier to see
  26how the indentation works if you have large indentations.
  27
  28Now, some people will claim that having 8-character indentations makes
  29the code move too far to the right, and makes it hard to read on a
  3080-character terminal screen.  The answer to that is that if you need
  31more than 3 levels of indentation, you're screwed anyway, and should fix
  32your program.
  33
  34In short, 8-char indents make things easier to read, and have the added
  35benefit of warning you when you're nesting your functions too deep.
  36Heed that warning.
  37
  38The preferred way to ease multiple indentation levels in a switch statement is
  39to align the "switch" and its subordinate "case" labels in the same column
  40instead of "double-indenting" the "case" labels.  E.g.:
  41
  42        switch (suffix) {
  43        case 'G':
  44        case 'g':
  45                mem <<= 30;
  46                break;
  47        case 'M':
  48        case 'm':
  49                mem <<= 20;
  50                break;
  51        case 'K':
  52        case 'k':
  53                mem <<= 10;
  54                /* fall through */
  55        default:
  56                break;
  57        }
  58
  59
  60Don't put multiple statements on a single line unless you have
  61something to hide:
  62
  63        if (condition) do_this;
  64          do_something_everytime;
  65
  66Don't put multiple assignments on a single line either.  Kernel coding style
  67is super simple.  Avoid tricky expressions.
  68
  69Outside of comments, documentation and except in Kconfig, spaces are never
  70used for indentation, and the above example is deliberately broken.
  71
  72Get a decent editor and don't leave whitespace at the end of lines.
  73
  74
  75                Chapter 2: Breaking long lines and strings
  76
  77Coding style is all about readability and maintainability using commonly
  78available tools.
  79
  80The limit on the length of lines is 80 columns and this is a strongly
  81preferred limit.
  82
  83Statements longer than 80 columns will be broken into sensible chunks.
  84Descendants are always substantially shorter than the parent and are placed
  85substantially to the right. The same applies to function headers with a long
  86argument list. Long strings are as well broken into shorter strings. The
  87only exception to this is where exceeding 80 columns significantly increases
  88readability and does not hide information.
  89
  90void fun(int a, int b, int c)
  91{
  92        if (condition)
  93                printk(KERN_WARNING "Warning this is a long printk with "
  94                                                "3 parameters a: %u b: %u "
  95                                                "c: %u \n", a, b, c);
  96        else
  97                next_statement;
  98}
  99
 100                Chapter 3: Placing Braces and Spaces
 101
 102The other issue that always comes up in C styling is the placement of
 103braces.  Unlike the indent size, there are few technical reasons to
 104choose one placement strategy over the other, but the preferred way, as
 105shown to us by the prophets Kernighan and Ritchie, is to put the opening
 106brace last on the line, and put the closing brace first, thusly:
 107
 108        if (x is true) {
 109                we do y
 110        }
 111
 112This applies to all non-function statement blocks (if, switch, for,
 113while, do).  E.g.:
 114
 115        switch (action) {
 116        case KOBJ_ADD:
 117                return "add";
 118        case KOBJ_REMOVE:
 119                return "remove";
 120        case KOBJ_CHANGE:
 121                return "change";
 122        default:
 123                return NULL;
 124        }
 125
 126However, there is one special case, namely functions: they have the
 127opening brace at the beginning of the next line, thus:
 128
 129        int function(int x)
 130        {
 131                body of function
 132        }
 133
 134Heretic people all over the world have claimed that this inconsistency
 135is ...  well ...  inconsistent, but all right-thinking people know that
 136(a) K&R are _right_ and (b) K&R are right.  Besides, functions are
 137special anyway (you can't nest them in C).
 138
 139Note that the closing brace is empty on a line of its own, _except_ in
 140the cases where it is followed by a continuation of the same statement,
 141ie a "while" in a do-statement or an "else" in an if-statement, like
 142this:
 143
 144        do {
 145                body of do-loop
 146        } while (condition);
 147
 148and
 149
 150        if (x == y) {
 151                ..
 152        } else if (x > y) {
 153                ...
 154        } else {
 155                ....
 156        }
 157
 158Rationale: K&R.
 159
 160Also, note that this brace-placement also minimizes the number of empty
 161(or almost empty) lines, without any loss of readability.  Thus, as the
 162supply of new-lines on your screen is not a renewable resource (think
 16325-line terminal screens here), you have more empty lines to put
 164comments on.
 165
 166Do not unnecessarily use braces where a single statement will do.
 167
 168if (condition)
 169        action();
 170
 171This does not apply if one branch of a conditional statement is a single
 172statement. Use braces in both branches.
 173
 174if (condition) {
 175        do_this();
 176        do_that();
 177} else {
 178        otherwise();
 179}
 180
 181                3.1:  Spaces
 182
 183Linux kernel style for use of spaces depends (mostly) on
 184function-versus-keyword usage.  Use a space after (most) keywords.  The
 185notable exceptions are sizeof, typeof, alignof, and __attribute__, which look
 186somewhat like functions (and are usually used with parentheses in Linux,

  o63ngSin:mn

void fun(int a, int b, int c)

 1ion/CodingStyle#L67" id="L67" class="li "Wa1rning this is a long pri1ntk w1th "
}
 115        switch (action) {
  68 140" class="li5        switch (action) {

 168if (condition)
}
 100                Chapter 3: Placi2g Braces 2nd Spaces
 162supply of new-lines on your scre2le#L102" 2d="L102" class="line" na2e="L120ne" name="L82">184" cl="lin*="line="L1djatatioation/Cdatayine"yle#ass="lineine"yle#Lati2supply of new-lines on your scre2lL23" id="tyling is the placement 2f

 174if (condition) {
}
 o="line" mem>Ra"> nn/Co*pt11=nn/Co**e="pt1179}
}
 108        if (x is true) {

 181                3.1:  Spaces
   ^ e="L5= "L153= "== "!= "?  /a>
   *  +  - e~ "! adingSt le#L186  id="L18 Lss="line" nam ="L24">49
   names9">  ne    nameunar" opme="or
 139Note that the closing brace is e2ve";2   names9">  ne    nameunar" opme="or
                Linux kernel coding sty#L23" id="LL23" class="line" name="La hr2"line"le#Latt185" cl"outylL41" "lin.="linele#L2" cla-thod=" clasrtructuef=meme="L1pme="or
 174if (condition) {
  73if (condition) {
 12n
is=ert" class="line" name128" class="lnew name="L/a>the code move too far to the right, ve large iindentations.

  ="L7upLati2supply of new-lines on your scre2ving 8-chaaracter indentations makee="L129"> 12putti"L5ae="L1umentad37n/Cod, sume=as L31">  ="L73"hrefanke="L1ass=sclass"don/a>and NOT read it.  Burn them, itƈ and makess it hard to read on a
  ="L7upLCod/aname=""L14aid="L94ngSline" class="li/a>
 181                3.1:  Spaces
">  1">  ngStylpaL11e name="Ltatiduc3"ingSline" class="li6" claass1                3.1:  Spaces
 ; hmentatioL31n/Codi"L5ae=erithe code move too far to the right, le#L134" 2d="L134" class="line" na2e="L124"> 13menpaL11e ,Codingmayle#L35lass="paL11e n name="Leri
at your screen for 20 straight hoursle#L139" 2d="L139" class="line" na2e="L129"> 139Note that the closing brace is e2pty on a 2ine of its own, _except_2in

  o63n76">oL32">  3e#L16namiNote that the closing brace is e2 a contin2ation of the same statem2nt,
<2 href=n76"Pasame=">  33  33 142this:
  3ce="L55136(a) K&R are _right_ and (b) 2ngStyle#L243" id="L143" class="lin2" nam2="L143variableL2" clatmpname="L9"L186"ingmume=n5" class=writo63n76"id="Coding/Cod="li6(a) K&R are _right_ and (b) 2ne#L134" 2d="L144" class="line" na2e="L124"> 14difficdonumentname=1"> /a>
 115        switch (action) {
uptyle#L5" i.62vam stas"d="5        switch (action) {
80-character terminal screen.  The 2le#L148" 2d="L148" class="line" na2e="L128"> 1432"otlass="fes=e/a>
 139Note that the closing brace is e2le#L150" 2d="L150" class="line" na2e="L120"> 15GLOBAL=variablee#(a    n/href=L31">  _re85" _ 31be 3.
 132        }
  3ce="L55136(a) K&R are _right_ and (b) 2 href="Do2umentation/CodingStyle#L253" i2="L153ne" namoutt_L170va_   6"()2" claso"L68"ilar id="L32">  3_id=_3ce="Li"Lne" namntusr()2" cla/a>
 174if (condition) {
 1ingSty nadam  od -tion/Comp nar"L136sion/Ce#L1s id="L13 claass1                3.1:  Spaces
  33(a) K&R are _right_ and (b) 2 e#L148" 2d="L158" class="line" na2e="L128"> 15s="linbuggy ">  33<

 16LOCAL=variablem stas"32">  3>a cumentaclasLoe" name="L/  Iclass="lina>
 14"couttatioLt"32">  3"> bably3>a ce="
 14_couttat2" classlile#Lptiduc70vaioL31n/CodingSnoime="css="lina>

  o  3a temporar"me="L2/a>
 115        switch (action) {
 16Iclass=L87" fty n/"> mix7upLe#L16locme=variablem stas63ass="lineane="L15        switch (action) {
 bld="L"L186"ingce=" 16Se4"> L101" 6 (Fss="lin<138
 100                Chapter 3: Placi2le#L171" 2d="L171" class="line" na2e="L127/CodingStyle#L101" id="L101" 5: T#L1def/a>the code move too far to the right,  of a con2itional statement is a s2ngle
2  72Get a decent editor and don't l2nches.
ayle#L73" id184"" id="LCodinname="vps_t2" cla/a>
 174if (condition) {
80-character terminal screen.  The 2entation/2odingStyle#L176" id="L172" cla27 16                Chapter 1: Indentat2entation/2odingStyle#L177" id="L172" cla2s="line" name=vps_t a79}
 108        if (x is true) {
        if (x is true) {
 18Inmentata="L1ifoLt"3ay/a>the code move too far to the right, ref="Docu2entation/CodingStyle#L182" id=28 72Get a decent editor and don't l2le#L183" 2d="L183" class="line" na2e="L128class="line" ntruct virtual_"L14aid1" *a79}
 174if (condition) {

 name=""> 16tion/Co#L1def/e name=helplass="line" 2" cla/ Not"3o 87 137special anyway (you can't ne2nignof>st23ocumenngStyle#L106" id=26.51<2class=ta/fulionef=d="/a>
Outside of comments, documentation 2#L90" id=2"L90" class="line" name=2"L90"2  90Outside of comments, documentation 2ef="Docum2entation/CodingStyle#L912" id=29/CodingStywntation/"bjectnsl138
Get a decent editor and don't l2ees depen2rning this is a long pri2ntk w2th "
 115        switch (action) {
 12mnd="L" id="LCodin101_t etc. " name="n/Coda>
  89<"n/Cod/a>
n_nelps_ alass="linus 132        }
 L41" id=/a>
 102The other issue that always come3lL23" id=3tyling is the placement 3f
 erfectef=d"L1uo#L1def/" idine" nameC#Lumen="li2The other issue that always come3lL34" id="few technical reasons to3
 115        switch (action) {
bneaL_"L104"_nd="L" ito align the "switch" and he closin3 brace first, thusly:
 o="name="L9tle#Ln/Cod" classnom"L104"14">di2The other issue that always come3lL38" id="d="L108" class="line" na3e="L138"> 108        if (x is true) {
 o="lmyflags_t79}
The limit on the length of lines is3CodingSty3e#L111" id="L111" class=3line"3name="L111" id=L31n/CodingSa111/ar3"L104"1d="Lwhyionetname cer4aid ciron =1"> 182
int2" clasle#Ltname entati"line"urumentssm cla bn2
 o="name="L9tle#L" idtiomeans"go a" nasle#Lt84""Le#L1def/a>
 174if (condition) {
Ra">14">ne"er85" n>  8tneaL_new_"e#L1ad="5        switch (action) {
Coding style is all about readabili3CL28" id=3href="Documentation/Codi3gStyl3#L118" (d) N="li#L1s "L186"85">ile#Lname=line1"> ard C99ie#L1s, id cer4aida>Coding style is all about readabili3CDocument3ation/CodingStyle#L119" 3d="L139" class="locumentat" idiron =1"> 18/a>
The limit on the length of lines is3o trying 3to define the value of P3d="L131" class="lAdine" nai"L1">  3onef=t="l5ae=umen amoutt""linimend="L" e eyfe="L1a>The limit on the length of lines is3oe#L112" 3" id="L22" class="line" 3dingS3yle#L122" iSty na4">bn3" i3acdustomeasLoe" nae1"> ard i#L1s Codinn clauint32_2" cla/a>and NOT read it.  Burn them, itƉ#L23" id=3LL23" class="line" name=3La hr3"line" nameentat name=""bjectnLoe" ni"L184"id="L1/a>
 174if (condition) {
68" valettli"L186"85">ile#Lname=line1"> ard e#L1s ioda>
 atory  nanew tad37oclass=on/CodingStyle#L67" id="L67" class="l3 L28" id=3"L28" class="line" name=3menta32"L98" clasow165
 129        int function(int x)

  3coL89">sLoe" naexiso"L62thoice n namee="codd/a>
 102The other issue that always come3 134Heretic people all over the worl3 have cla3med that this inconsiste3cy
vig"L84"menta/rs="li6"wa cenati2supply of new-lines on your scre3ut all ri3ht-thinking people know 3hat
<33" class="lL68" c5 C99ie#L1s3 claassid="184"L41" "linu32="line89">s="L71.me="L16wda>
8"ilarie#L1s3s="lllLrtructuefe="L186"85">shlc52a>

 139Note that the closing brace is e3pty on a 3ine of its own, _except_3in
  3>asnamely3>a menNEVER9Note that the closing brace is e3 a contin3ation of the same statem3nt,
<3 href=EVERLt84""Le#L1defLtnlingm" classn11/arlyle#ame=oL1umenonosoerule8/a>
 102The other issue that always come3ngStyle#L343" id="L143" class="lin3" nam3="L143Id gener85,L17 e="Ls=,yle#Llntruct mee="has el  nam name="assn"L104"ably2The other issue that always come3ne#L134" 3d="L144" class="line" na3e="L134"> 14>a d c5ctef=acding5d 32">  3_intat_>bneaLe#L1def/a>
 115        switch (action) {
                Chapter 1: Indentat3aamp;R ar3entation/CodingStyle#L143" id=3L147" class="lL101" id="L101" 6: Fss="lin                Chapter 1: Indentat3aL28" id=3d="L148" class="line" na3e="L138"> 148and
 13Fss="lin<"32">  3>a cumenL876">weentaclasdo juti oL1ue="L65"> 18y"32">  8and
 15fationStyleoid=woyle#L16fuls73">tname(lineISO/ANSI63" id="dingingS80x24/a>and NOT read it.  Burn them, itƉcumentati3n/CodingStyle#L151" id="3151" 3lass=" id=""lllLL136)taclasdo oL1ue="L6aclasdo ame="tati/a>
 102The other issue that always come3 href="Do3umentation/CodingStyle#L353" i35ef="Docummaximum letgthaid="Lass="line=s3s=atioL71"ingSmentat" iLoe" n2The other issue that always come3 e#L134" 3CodingStyle#L154" id="L134" cl35"> 17Complexi9" class=le#L27" idlntalumenona" name="L1/  Sn,=L31">  "linea2The other issue that always come3 n/Coding3ingStyle#L155" id="L155"3class35" name=numend="L  >8"me="ass="lineion/C=s3juti oL1u o="l(ss=">8"me=69        action();
  "line4">diu ots73">sme="L55id="Lfle#Ll otaida>
  lineaL o="ee#ass="lin/a>
 158Rationale: K&R.
The other issue that always come3 ty on a 3d="L160" class="line" na3e="L130"> 16ling-clas-gif85d ame="-y/ar3high-s"DoclLrtu#L104m cla id="ntada>Coding style is all about readabili3ent also 3inimizes the number of e3pty
<3 href=tname=1"> ywntation/ass="line=s3e="LagSty, d="L32">  3ad67" cooe" n2The other issue that always come3any loss 3f readability.  Thus, as3the
<3 href=maximum l8"its3e="Lion/="linCodiL7185" id=nelpee#ass="lin="L86"4if (condition) {
 num-" iLname63n76"ati167">"> bably3diua bet85" jobs="lina>
 11classass=1">  3class#oL1138
 166Do not unnecessarily use braces 3le large 3nndentations.
 18y2The other issue that always come3ae#L148" 3d="L168" class="line" na3e="L136"> 1432">  #L73" idocum5d 5-10,yle#assL73" rss#o"L6a name="L62wroL65">Re-"> 16tion2The other issue that always come3aentation3gStyle#L169" id="L169" c3ass="3  69sme="s="pientatioA humssn>ty naass1                3.1:  Spaces
 10gener85ly3n5" ly3keepCengckaid="gStyl7 diffea idi55id="taclye="L62="li6(a) K&R are _right_ and (b) 3le#L171" 3d="L171" class="line" na3e="L137href=n76"=engyle#"linus"d/  Yss=L136"assL73" rssbr67"ia136" id=maybe"assL73" d"> 142this:
 ywntatass=did 2"taeksssrom idw38
Anyway, here goes:
 17In"Le="L1 3/0""tasepar8tneass="lin="L86"Style#fanke="L1assIline" ass="line=sa>Anyway, here goes:
 110ngStylEXPORT*asscro otai  3"> babl41" id immedn " ng5dne" naix8tyle#L1y, here goes:
     ne=sa>Any0" id=Iline" /a>
 103  sys"16_is_up(inus       action();
 "> 124 183nmentaGet aEXPORT_SYMBOL(sys"16_is_up}
 1738"Le="L1 ne=sa>Anyy3dtoid cer4aicl cl="Licume" n" clasle#fa84"id=d"yleid ceoL" clai2">184" cltion/Coda href="Documentation/CodingSt3nches.
a 3d="L166d __attribute__, 2hich 23 16     beca   6"2"> 172
  89<"n/Cod/a eyfe="L  gSerRationale: K&R.
  6xiso"L> 132  ay, here goes:
void fun(int a, int b, int c)
y (dptbyname=""bjectngStylettli"L186 ass="ligo ard e="L172"> fun(int a, int b, int c)
 113  aria86"Sty32">  mnar"tm27">orks L31">  le#anup  namL_"L10href="Documentation/CodingStyle3eL28" i" 3d="L166ot;c: %u \n&q2uot;,23, b, 39/a>Do not unnecessarily use braces 3le larg u2yle#L93" id="L97" class=2"line23name=3L97"oc04"11aline" x24/if (condition)
 ywntatasatas41" id (condition)
to alL  gSlind
to as="vidu" n 6xi=,yle#s6"2t84mak#L1y, here goes:
 1040" iSty namcumfiia86"Sty3rx88">va hind
  33orkso635" ie" nL  gSndana>

if (condition) {
 114  ne=(a       action();
a>and  = 0
 1040d="L118" clasaL11_rbui55i = kpienoc(SIZE}
 L175bui55i == NULL       action();
 124<-ENOMEM
The other issue that always come3 href=4d=3blocks4(if, switch, for,3 L175ass="line1>        do_this();
 1741" name="L154"> 154        do_this();
                   >        }
 156and  = 1
 >        }
 "> 124and 
 174if 156 165<#L1y, here goes:
 165 165<#L1nalia>Note that the closing brace is e3 a con4ch3aracte4 indentations mak3e="L134"> 124  trsse=1expl1 165<:assOK/">  " claclass/Cohe other issue that always come3lL38" 4ke3s it h4rd to read on a
<3 id="3430" c4ass=Wln76"i  33
"="_mist="wast
 104The other issue that always come3  3wana>cme=v18 165ne nWHATocme=v186"8Lmea,a"L41HOWhref="Documentation/CodingStyle3 134HeAls8, trsse=1linus 5ae="L1u18 165Ra i4line=s3s=atbody:odingSaref="Documentation/CodingStyle3
 134Noass="line=s3ne",a>ne L65""bjectns=didit8Lmea,a"Ls=                3.1:  Spaces
 104ThCo"L6c> 165<#L1s="li184" idAPI132  ainpe#L73"" "linu3184" i-doc 9<"n/Chref="Documentation/CodingStyle3 144a d c5otaidetaile 114        switch (action) {
     n/Cod sa hrlotai18 165  33   */rtructuef hr 144and
 134ss="liTix88"> 84" clsa hrlotais=">8"multi"L138)i18 165 1544void fun(int a, int b, int c)
 1045ass="l=  +  - *class=i>  33 84" clsa hrlotaimulti"L138fun(int a, int b, int c)
sat-e#L13fi184" id3/0""ta
 17453ss="l=  +  - *cPe#L73"" "lia>
<>Rast<, enhref="Documentation/CodingStyle3    *fun(int a, int b, int c)
 1545d="L118" class*/a href="Documentation/CodingSt3nches.4d 3" id="4tyle#L159" id="L139" cl34 59
 164ing-clss="_mist=ls85imy3acdn/Ce#Lli 165<=d"yl,tione" n2" id="m">ly3>as="lllLtaiderivind
        switch (action) {
ioLrefanssn11/roomlotaida5id="L18 165< ="Docum      switch (action) {
to at">  o 114        switch (action) {
 1646e" name="L156"> 156 1442">  #T=diOK/">  li,LL136)tadoL136"a="_mivumy3>a ce="  33        switch (action) {
 1046  ="L7up="L3ue#L1="_mivumnoCoa"Docuassn class"Lmean"tati/ainerule"32defaultsa href="Documentation/CodingStyle3aation4" 3d="L174" class="line" na3e="L134href=476"=enleoid"m">classs=1">desira9"> (rtrLact,2" id="m">wone"er=1">8"teCoref="Documentation/CodingStyle3aation4" 3f read4 statement is a s3ngle
34 72t"L161locme=vmonkeys5" cl nae="s=GNU emactclass#obneaLref="Documentation/CodingStyle3aation4"=3e#L1334ocumentation/Codi3gStyl34 13Anywamumen aame=m
 174if (condition) {
  nLsktioneie" n2get ridme=vGNU emactsL73"L5" c"lia>e#L1defsanaLref="Documentation/CodingStyle3aation4" 3d="L164yle#L176" id="L172" cla24 16     >
 104  (defun c"L138up-arglast-tabs-"l5ae(igno" c       action();

 1848Style#L101" id(columnt(c"L" c"lem-2nd-pos c"sya-e=fset))       action();
 17483ss="l=  (* (mad sa  c-ly3>a-e=fset))       action();
 156;; Ena9"> 184" idmodea eyfe="Laptat"ri="linepar      action();
 156 156 154 1149line" s9">           (c"set-e=fset 2="liarglast-1" *-nonempthe other issue that always come3ae#L144" 3d="L164ot;c: %u \n&q2uot;,24, b, 49e" name="L156"> 156if (condition)
 bablmumenemactcgoablass/Cle#fa84" 184" idcumentlsa hrlotaiC (condition)
                3.1:  Spaces
 1050" iStBu>Codin="> 163to al lost:L1defnt2" cla idla>
if (condition) {
 115  Now, an/Co,vGNU la idl  namL arda9"7ss1be 3.tgas"(ia>a f7oclamry  iL1383ostaont  "L41tooaba=ineeca   6odin=inCodumersme=vGNU la idla href="Documentation/CodingSt3le#L165s73r, but5ton/CodingStyle#L298" i25"> 1050d="L1recogn" nLe="Lauth73ss=le=vK&RSO/ANSGNU "bjectnaredocum5d 5vil,2" id="m"a href="Documentation/CodingSt3le#L165s83r, but5tlass="line" name2="L9925 clas50/a>No1u o=s31aslus"misguide=mselv1
The other issue that always come3 href=5d=3blocks5(if, switch, for,3

 1751" namre-9<"n/C<#L1/nonemay3wana>umen alook3da>
e other issue that always come3 href=5dh3r, but5" class="line" na3e="L135class5"line"reme1loc:fnt2" cla idla>
Coding style is all about readabili3CL28" 5"="d="L105ocumentation/Codi3gStyl35L118"51d="L118" class="L101" 6: Fss=10: Krumenturumentssm clainepar      action();

ti        }

 175if (condition) {
 1252"line"e#L1defd=Ena9"> auexiso"LinffoLte="L186ssn"L104"abeen_namle#fa5        switch (action) {
184" id3ubsys"16,s L31">  SE#L13fi(ngce="21.3        switch (action) {
 1avcimlasag-srou}put)2 10531" name="L156">auexiso"Lle#forulCONFIG_AUDITSYSCALLhref="Documentation/CodingStyle3ee clo5d=3e#L1335 id="L133" class=3line"35ame="53/a>Linux kernel style for use of spaces de5=/3odingS5" class="line" na3e="L135"> 135HeFeaL186"8sn"L1d="ntastbablbe>
<>Raatie entsta9"> >a cumenL8def 13538" name="L156b#L10a>
 >        }
 105Thixed-"serious betangocous feaL186"8( L31">  n76"i supy3aclotai1>Coding style is all about readabili3CDocum5i=3e#L1335"L143" class="lin3" nam35"L1435d geneneparys"16s)3ad67" coov>Coie"er=lai2"ooia<, enaa>sat-iri2"ooptastrcumhe other issue that always come3lL38" 5i/3odingS5" class="line" na3e="L135"> 1454/a>if (condition) {
 1154numend="entuADFS_FS_RW (condition) {
 14547ame="L170"> >        }
 1354
 1554name=Ftaifu)tadotation/Codid="/Cod=rumentssm clainepar8tne1"="lineparef="Documentation/CodingStyle2le#L165ti3n/Codi5gStyle#L151" id="3151" 35ass="55Styleentation/Codin1build/krument-o63n76">.txw       }
 105The other issue that always come3 href=5t=3e#L1335ion/CodingStyle#L353" i35ef="D55/a>Linux kernel style for use of spaces de5" 3Coding5tyle#L154" id="L134" cl35"> 1755" name="L154"> 154        switch (action) {
aL_newasatasdeefeoye=mselad67" colways  nv8d
 1555d="L1re55id="ta
>colletion/1Lmeadocum5d 5-ist4(atad

>colletion/1/arL id e#L27"efficie=")"ingce=d
 165ing-clo a" nclassnoneabsolu"lus"_ nv8_>neaL o="ee 32">aexiso"Ld"yleefe="L186mselass=llela-id=dn" c5 o=iL1y, here goes:
 115  eeca   6gSad=sleptataidideL62wroL65"elselotaidaixed-Ly, here goes:
 165Do not unnecessarily use braces 3le lar5e 3nndent5tions.
 1452">  #Lrik#L11/arn_namexigckaid"yleefe="L186"acoh5id=",aixed-"re55id="ty, here goes:
 172memnew man6">midl gechniquenelpe8"me="bothlc52aa>be10ngatad
 1056  ="L" id="m"> atoL_"L10d/  Yss=mle#faocum"mentaLy, here goes:
be >diu owomenonasme=vre55id="ta
Anywa"2t84lasentati"li/a>ne=vidi55id="tnt2" crntat ta8" id2Td3ubrntata
 175ife="L161locme=v3ubrntatali/a>o oL1ueecr>midlamL arglobn =1Do not unnecessarily use braces 3le lar5n/2odingS5yle#L177" id="L172" cla25="lin57Codin:mn
a j4"abeef 105  memnew man6">midl (a8" idcee="ham6_14e="ha8" idham6_li/a>noL1um6_

 1858StyleReme1loc:fifa5   on  gS j4"afi3ue#L1rid"yleefe="L186="L3ue#L1tdid184"" fun(int a, int b, int c)
  3elnar"i1>Codine="Complexbu"Ly, here goes:
 1758/a>if (condition) {
            6: Fss=12: Mscro>o E161>noL1uRTL (condition) {
                Chapter 1: Indentat2usuall5a/2odingS5 parentheses in L2nux,
25 href58CodinNam ame(lsscrosLdefL1u18tsta5nom">aapitol68">Ly, here goes:
Rationale: K&R.
void fun(int a, int b, int c)
nom">mt> 84" cl"2t84defL1us31asn =relnewas18tsta5aptan c (dptbe"asscrosL86"e1ll>L1u32  ay, here goes:
 1159/a>        switch (action) {
mt> 84a9"> e#LsscrosL86"e1ll>L1u32  aLy, here goes:
ifMscro>mle#fa ultip
                  \ref="Documentation/CodingStyle2le#L166s 3nd Spa6es
                               \ref="Documentation/CodingStyle2le#L166s13nd Spa6elass="line" name2="L9226"> 10601" name="L156"> 156                \ref="Documentation/CodingStyle2le#L166s23nd Spa6eStyle#L93" id="L293" c26ss="l602" name="L156"> 156 1160/a>        switch (action) {
he other issue that always come3lL38" 6s63r, but6t id="L97" class=2"line266lass60Coding style is all about readabili3CL28" 6s73r, but6ton/CodingStyle#L298" i26"> 1060d="L11)LsscrosLThff="a21" *rol f idhe other issue that always come3lL38" 6s83r, but6tlass="line" name2="L9926 clas60/a>Note that the closing brace is e3pty on6ta3ion/Co6ingStyle#L110" id3"L11036 80                             \ref="Documentation/CodingStyle2le#L166ty3e#L1116 id="L111" class=3line"36ame="61Style#L101" ido { s9">                               \ref="Documentation/CodingStyle2le#L166" 3d="L116" class="line" na3e="L136182" 611" name="L156"> 156           \ref="Documentation/CodingStyle2le#L166"23nd Spa6(if, switch, for,3 156 124<-EBUGGERED;      \ref="Documentation/CodingStyle2le#L166"33nd Spa6yle#L114" id="L113" cla36"> 1761" name="L154"}aixed-(0)y, here goes:
 172_eaLy_iba=th4line=s3s=ata metbe"a 6xiidlasdnt2" crae L65a8" id      action();
Codinne=s3s=a;tdid184""  breaomp nainFsse" npari/a>ne=vth" iaixo> babl  gS  33Rationale: K&R.
Tdepetain/1 o=iL1n aloiable85"> 18mle#fa5Lssgic 3d="he other issue that always come3lL38" 6ia3ion/Co6="Documentation/C3dingS36 80x,7>
<)y, here goes:
The other issue that always come3 href=6d=3LL23" 6lass="line" name=3La hr36line"622ame=d="ntalook3a>th4liame=mroL65inerul>"="_mistd/  YsiL1n sss="l "2t84nke=  gSs gSaref="Documentation/CodingStyle3 176if186"8167">"="_mistprnke=to breao6">>w38nocidl L5" c"aLy, here goes:
Threen_nam ssl->
 bab      switch (action) {
  3L17L62wbody e.g.  124slFOOae="s=d=uineRationale: K&R.
 1262"line4)lotaget<#L1s diffetan edd="t:lsscrosLdefL1u18tsta5  ay, here goes:
  mselassa hheeoi  Bewhreee=v3imilar issulasle#fy, here goes:
 106The other issue that always come3Li#def 136He#def        switch (action) {
mle#fa scrosLexhau oively./a>TdgccainFsse" s manu" n=ls8      switch (action) {
nRTLingce="aa>sat-e184" iLy, here goes:
Rationale: K&R.
 1363/a>Note that the closing brace is e3pty on6de3s it h6its own, _except_3in
 156   6: Fss=13: Pri5                3.1:  Spaces
 106ThK84" iddnonaop/a>na>th4L_"L10s/d"  ssl6"is="l. Do mi3uelasd3pne L65              3.1:  Spaces
  . Do "L41"s">aLipplend
 1464/a>ifword>na>th4a8" iddidha8" id;L1defnt2" cdo "L4assn>a taia8" iddid184"" a>
 1164numend="cise, le#ar="L3ueu3s=biguouaLy, here goes:
diu o_"L10"ismi3ale=mle#faaa="lio>Ly, here goes:
 146and
 1364

a cumenL8linus">Ly, here goes:
 1564void fun(int a, int b, int c)
 1065/a>Thixee=">  3ad67" c   6g#Lssth4s186mmlasag-s ati"L1umenamexi
 1765" namdev_info(do oL1usolotathThred184""  154o c (dptle#faa      action();
  "Limentnamadnoice,l<lL13f/184" iLh&gid8def 1565d="L1>  3>diu oh16,s" id=j4"abee heug-"s="liotairemot6ssroublead6o
a cumenL8r"t9="Ldleut "2t84lasdDEBUG symbolL7s8" c5defd
 166ing-clis,"Eyadefault " id="m"> atoi="5us">)2  3   6dev_dbg()aortpr_debug(),      action();
  "uton/CoapobyoDEBUGLy, here goes:
 116        switch (action) {
 1666e" name="L156"> 156 1462">  #T=32184" idprovus"smp na41" idl nagy3n5"  purp" igmemnew alaria8or>he other issue that always come3lL38" 6oh3aracte6L169" id="L169" c3ass="36 69 84mexi
 1066  ="Ldotation/Codidftaifura>   info"n/Codid diffe> amLy, here goes:
 84" clfo"ndftaipmeniL1n as" nL> 1aeefe="L=i>  33<41" idl nhe other issue that always come3lL38" 6"=3e#L1336ocumentation/Codi3gStyl36 13Linux kernel style for use of spaces de6"n3re emp6" class="line" na3e="L136"> 1767" name="L154"p = kmalari(s" nof(*pdo ...}
        switch (action) {
 18mid c1/arL5" c"ad
 106  brule"32184" spondnew s" nof e/a>Tlai25s"eamexiagmemnew alaria8orL7s8" cLy, here goes:
 124<>
i        }
 1868Stylew38.      }
 1768/a>if (condition) {
            6: Fss=15:1Tod=ine                Chapter 1: Indentat2usuall6a/2odingS6 parentheses in L2nux,
26 href68CodinTasentappeaa>neaLbee hli 1didmiLpnrcestaon e/a>Tgcca namdassgic a8" idmsth49"      action();
Raf stpup=ostaonta me>pont2" cla6" ia8" id28tne1" 6: Fss=12),a href="Documentation/CodingStyle3aation6" 3d="L166lass="line" name=2"L90"26 90void eaLyne=tenL7s8" cL Abunda="<   6
 18m eyfe="Lpag-cac33. Ju o=roL6kd diffeiid="Lpag-cac33dmiLs j4leoid"      switch (action) {
 1169/a>  sn"L104"agoae="s=hheeo 5dmilis#rumdsL      action();
 rul 6
  o "L4 pffeineifr=1">3sIlin/6
sat-mL Aniemcestaon ea " ioLrul 6a86ssod=raeoidwasen      action();
 knownneaLbee hli 9="L"L" e18tsta5<,aatasaslexresult e(li=la      action();
  3*know*le"3218 9="Lr> bablbee 9"> e#Lostam" nLnar"io> 163       switch (action) {
 10701" naat-e1malari(duine 1170/a>  "l5ae"l"t"
d
 
 1070d="L1appeaa>noruweighs4lasdpot<, iable8lu 6

ells2gccaots73d
                3.1:  Spaces
 156 124<>
Linux kernel style for use of spaces de7"33nd Spa7yle#L114" id="L113" cla37"> 1771" namF="L86"Sty04"ar> 124<>
   oneln="L86"Ss L3c>be10         switch (action) {
teg        switch (action) {
Codin(-Exxx =ss)aortafnt2" c L3c>be10rtructub#L1 a" (0 =Ranon-zero =< L3c>ss)Ly, here goes:
Coil323/0""taofref="Documentation/CodingStyle2le#L167g 3to def7ne the value of P3d="L137" cla7s="lAdddi5entnt-to-fi3uebug/aa>"5us">1aeefeoag3dis8soL86"Sref="Documentation/CodingStyle2le#L167g 3d="L11722" class="line" 3dingS37le#L172/a>ThbeuweenL7>teg  /ad  ib#L1 a"s4lasnle"3218 9="Lr> ass#ofi3uelass3dmiL>umesref="Documentation/CodingStyle2le#L167g23nd Spa7lass="line" name=3La hr37line"722ame=f73"  ...nerul>"1Lmeadocum5d<="La s="lip86va hs L31"bug/,ealways 41" idli=la      action();
 177if18tva h>  he other issue that always come3lL38" 7ia3lly wh7n you've been3line"37ame="72/a>        switch (action) {
 1aen="L86"Ssi/a4"aaL86"Ssortanmimtis="ivellamry  =      switch (action) {
 124<4"aerror-c86"8a>teg  .56afo 33<2" c      switch (action) {
 124<4fnt2" c L3c>be10rtructub#L1 a"Ly, here goes:
 1272

 124s 0e other issue that always come3sssort-EBUSYdftaifail186
 107Tha p86diia8e,iatas
 124s 13L17its L3c>besu7" not unnecessarily use braces 3le lar7d=3e#L1337 id="L133" class=3line"37ame="73 genenendnew a"L1umenew dnoice tai03L17itsLmeadocum5d< not unnecessarily use braces 3le lar7d="few te7" class="line" na3e="L137"> 1373/a>if (condition) {
  AllmEXPORT clf="L86"Stymu o=recnn t" 3ss=18tva h>  o oL1usolad67" colb      switch (action) {
  aL  Priv="li(d e=ic)lf="L86"Stya>be notinerul>"L7se other issue that always come31gSda>
 id=doLy, here goes:
Rationale: K&R.
 1373/a>NoF="L86"Stywh" iar> 124<>
  33ifr=1">d=uindiia8s"SsofL"2ta>   onelli 9u
be10,="m"> atosubjn t" 3d

 id=indiia8eifail186obyor> 124new so c1>ut-e=-r" c"d
 107Thresult<="Lypoa miemn
 ass#obeLn="L86"Stys el r> 124<5oinFsss;>
 id=   ref="Documentation/CodingStyle3 1474/a>if (condition) {
 1174/a>        switch (action) {
 156      switch (action) {
 1474">  #T=32h gSerinepaaa>"5us"/lL13f/184" iLh21" *aiStyoL161locme=vsscrosLg style is all about readabili3CL28" 7nh3aracte7149" class="line"3name=37"> 1374
  3ad67" c   , s=">   r=1">explicitenN18dnew so c1e85">nt e(li=em 163 self 1574name=Ftaiemn
 163be 3.ta mntnat6ssod=leng#fanfa4"aarray,f>umen dv>ntac"d
 107The other issue that always come3 href=7t=3e#L1337ion/CodingStyle#L353" i37ef="D752" name#def 1775/a>if (condition) {
  Similarly2"i> 163be 3.ta mntnat6ssod=s" nL> 1so c1d e="L186mme1loc,=   ref="Documentation/CodingStyle3 1575/a>Rationale: K&R.

Tdoastrc t" d c1cheik#L11/> 163tionale: K&R.
 167ing-cla>be 3t-mL  Fe idfreele#Lper   6gSel   gSerinepaae#Lne1"enti"elselistal  gSytionale: K&R.
s#L1ric"d1Ly, here goes:
Linux kernel style for use of spaces de7s/3odingS7y lines to put
 154   cruf>g style is all about readabili3CL28" 7og3tyle#L765" id="L165" cla3s="li37"> 117        switch (action) {
 1676e" naSo c1edi8or"acd=uinFsspr> =rumentssm claiinfo"n/Codide1lodde=msela/0""tanepar8      switch (action) {
 ssIlin/6ssrk"ad
 1472">  #a>th4L=iohe other issue that always come3lL38" 7oh3aracte7L169" id="L169" c3ass="37 69 1076  ="L-*-Lmode: c -*-ref="Documentation/CodingStyle2le#L167" 3d="L177" class="line" na3e="L137href=77/a>                3.1:  Spaces
th4L=iohe other issue that always come3lL38" 7"=3e#L1337ocumentation/Codi3gStyl37 13Linux kernel style for use of spaces de7"n3re emp7" class="line" na3e="L137"> 1777" nam/*nux kernel style for use of spaces de7"g3tyle#L7e#L175" id="L175"3class37line"77/a>  LoiablV85"> 18ohe other issue that always come3lL38" 7"D3cument7yle#L176" id="L172" cla27 16 107  */      action();
th4L=iohe other issue that always come3lL38" 7" 2d="L187" class="line" na2e="L127"> 1878/a>                3.1:  Spaces
 1778/a>ifDo "L41a>"5us"=d=y"mfelass3dsela/0""taneparL  Pbjectn>diu oh1icmewnL"brsonab      switch (action) {
7se other issue that always come3     a>"5us"ssssrk" asftaiita65diu so c1>">   ssgic 2wrooclfo"Lsst"o"Lina65RaworkN184" ctlyLy, here goes:
Note that the closing brace is e3pty on7" 3d="L167lass="line" name=2"L90"27 90void fun(int a, int b, int c)
                3.1:  Spaces
 156, S#rumdaEdi8odi      switch (action) {
 1179/a>  by B5">n W. K84"ig=1">d=d DennistM. Riumen1Ly, here goes:
ifURL: , here gohttp://cm.bell-labs.lam/cm/cs/cbrok/">http://cm.bell-labs.lam/cm/cs/cbrok/a>Linux kernel style for use of spaces de7"h3aracte7class="line" name2="L9927 69n W. K84"ig=1">d=d Rob P>thLy, here goes:
 10801" naAddison-Wesley, Inc., 1999Ly, here goes:
http://cm.bell-labs.lam/cm/cs/tpop/ 1180/a>        switch (action) {
  ext -afo"Lcpp,2gcc8      switch (action) {
 18m 38http://www.gnu.org/manu" /a>        switch (action) {
 1080/a>Rationale: K&R.
aC, URL: , here gohttp://www.opet-std.org/JTC1/SC22/WG14/">http://www.opet-std.org/JTC1/SC22/WG14/a>Rationale: K&R.
                3.1:  Spaces
ThK84" ides
Li, here gohttp://www.kroah.lam/lL13f/talks/ols_2002_184" i_18dnewslL38_talk/htm /">http://www.kroah.lam/lL13f/talks/ols_2002_184" i_18dnewslL38_talk/htm /a>                3.1:  Spaces
 1781/a>if (condition) {
Ra


T33LXR lamrunss=a>Ra,s ex="li aboul v/a>i ebyo, here gomailto:lxr@lL13f.no">lxr@lL13f.noa>Ra.
lxr.lL13f.notk#Lde="Cost>pobyo, here gohttp://www.redpill-linpro.no">Redpill Linpro ASa>Ra,sprovus"cme=vLL13fe18tsultiew aL1untis="i"Styseroiceslail"t"1995.