linux/Documentation/coccinelle.txt
<<
>>
Prefs
   1Copyright 2010 Nicolas Palix <npalix@diku.dk>
   2Copyright 2010 Julia Lawall <julia@diku.dk>
   3Copyright 2010 Gilles Muller <Gilles.Muller@lip6.fr>
   4
   5
   6 Getting Coccinelle
   7~~~~~~~~~~~~~~~~~~~~
   8
   9The semantic patches included in the kernel use the 'virtual rule'
  10feature which was introduced in Coccinelle version 0.1.11.
  11
  12Coccinelle (>=0.2.0) is available through the package manager
  13of many distributions, e.g. :
  14
  15 - Debian (>=squeeze)
  16 - Fedora (>=13)
  17 - Ubuntu (>=10.04 Lucid Lynx)
  18 - OpenSUSE
  19 - Arch Linux
  20 - NetBSD
  21 - FreeBSD
  22
  23
  24You can get the latest version released from the Coccinelle homepage at
  25http://coccinelle.lip6.fr/
  26
  27Information and tips about Coccinelle are also provided on the wiki
  28pages at http://cocci.ekstranet.diku.dk/wiki/doku.php
  29
  30Once you have it, run the following command:
  31
  32        ./configure
  33        make
  34
  35as a regular user, and install it with
  36
  37        sudo make install
  38
  39The semantic patches in the kernel will work best with Coccinelle version
  400.2.4 or later.  Using earlier versions may incur some parse errors in the
  41semantic patch code, but any results that are obtained should still be
  42correct.
  43
  44 Using Coccinelle on the Linux kernel
  45~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46
  47A Coccinelle-specific target is defined in the top level
  48Makefile. This target is named 'coccicheck' and calls the 'coccicheck'
  49front-end in the 'scripts' directory.
  50
  51Four modes are defined: patch, report, context, and org. The mode to
  52use is specified by setting the MODE variable with 'MODE=<mode>'.
  53
  54'patch' proposes a fix, when possible.
  55
  56'report' generates a list in the following format:
  57  file:line:column-column: message
  58
  59'context' highlights lines of interest and their context in a
  60diff-like style.Lines of interest are indicated with '-'.
  61
  62'org' generates a report in the Org mode format of Emacs.
  63
  64Note that not all semantic patches implement all modes. For easy use
  65of Coccinelle, the default mode is "chain" which tries the previous
  66modes in the order above until one succeeds.
  67
  68To make a report for every semantic patch, run the following command:
  69
  70        make coccicheck MODE=report
  71
  72NB: The 'report' mode is the default one.
  73
  74To produce patches, run:
  75
  76        make coccicheck MODE=patch
  77
  78
  79The coccicheck target applies every semantic patch available in the
  80sub-directories of 'scripts/coccinelle' to the entire Linux kernel.
  81
  href="+prefs?return=DocNetBv class="line" name="L82">  href="+09j6.49"
	  >
  v2.6.16.49
  
  1sl
	  >
ame="L606.16.49
  
  1sl
	  >
ame="L606.16.49  78

  v2.6.16.49
  e patche8, run:
53">  tname="L40">  40
  v2.6.16.49
  ="L75"> 875
  href="+prefs?reake cocc8check MODE=patch
  77
53 MODE 76" id=tion/coccinelle.txt#L77" id="L77" class=8atches inncluded in the kernel usic pa8ch ava hrewneltion/coccinelle.txt#L77" id="L77" class=8cinelle.8xt#L80" id="L80" class=8line"8umentation/coccinelle.txt#L71" id="L71" class9tion/coc9inelle.txt#L81" id="L819 clas9and org. The mode to
91~~~~~~~~~~~~~~~~~~~~~~xt#L6a ~~~~lame="L40">  40
 92ocumentation/coccinelle.txt#L47" id="L47" id="L47" class="line" name="L47">  47A Coccin9e patche9, run:
 975
  42<. In5">  6cas66">  6ocumentatmutiob80initialize.txt#Lnelle.txt#L75" id="L75" class="line" nam9line" na9e="L77">  77
  51Four mod9"Documen9ation/coccinelle.txt#L79" id=9L79" class="line" name="L79">  79The cocc9atches i9ncluded in the kernel u9ic pa98  1sl
	 ="L39Doc class="line" name="L76">  76        9n/coccineelle.txt#L10" id="L10" cline"9umentation/coccinelle.txt#L71" id="L71" class10xt#L11" idd="L11" class="line" name clame entation/coccinelle.txt#L78"COCCI.txt#Ly_SP.le.tx id=" id="L78" class="line" name="L78">  78
  72NB: The 10 name="L104">  14
  016 - Fedora (>=1305clameref="DComentll~~~~W one Fil 52Prot#ss53">  ccinelle.txt#L8" id="L8" class="line" name="L8">  10">  17 - Ubuntu (>=10.04 L06clame6ocumentation/coccinelle.txt#L47" id="L47" id="L47" ="L47" class="line" name="L47">  47A Coccin10ine" name0="L18">  18 - OpenSU07clameL79" By74" id="Lnelle.txt#L later.sourocucre53 class="line" name="L12">  12Coccinell0a> - Arch0 Linux
 - Ne0tBSD
  12Coccinellext#L11" iid="L11" class="line" namme="L11">  1l
	  xafaul,ncci0sdriatch/net/wi://css/L68" , buwritc class="line" name="L76">  76        1le (>=0..2.0) is available throug1clame package manager
  14
   16 - Fedora (>=133)
  76        1l">  17 - Ubuntu (>=10.04 LLucid11op level
  18 - OpenSUUSE
<117entationcinelC=1 CHECK=ve unta href="Documy.
corrduced in      2
  href="+prefs?r1> - FreeB1SD

  24You can 1get the l1atest version released f1rom t1e Coccne" nruns of 'scripts/cocciin a href="Documentat">  4" id="iableclass="line" name="L24">  24You can 1g (>=sqlle.txt#L25" id="L25" cl1ass="1ine" nCOCCI=ocumentatm buaddil/rially5b80uccinccionr"~ctor"~a ~~~~lanelle.txt#L75" id="L75" class="line" nam1ccinelle.1txt#L26" id="L26" class=1"line125" name="L42">  42< asnellwnmentatio  href="+prefs?r1>">  17  href="+prefs?r1> - Ne run the following comma1nd:
<1 href="Documentation/coccinelle.txt#L31" id="L131" class1="line" name="L31">  31<1/a>
<1 href=In5">.txm>corrt#Lrle.txnomen28">  28  78
  24You can 13 name="L144">  14
Pro2eri" inewhCoccinelle, the "Documentation/coccinelle.txt#L31" id="L13cinelle.1" name="L36">  36
  171  38
  "Documentation/coccinelle.txt#L46" id="L46" cl1ntic patc1hes in the kernel will w1ork b1st witd9; aoptcht;chaisinel81  81
  62'org1tion/cocc1inelle.txt#L41" id="L41"1 clas14and org. The mode to
  47A Coccin14 (>=squueeze)
  46
  file:line:column-column: message
  59'con1t#L48" id1="L48" class="line" name1="L4814L79" class="line" name="L79">  79The cocc1f="Docume1ntation/coccinelle.txt#L149" i1="L49"Exafaulation/coccinelle.txt#L58" id="L58" class=1eon/cocci1s="line" name="L50">  501
14href="Documentation/coccinelle.txt#L31" id="L1es are de1fined: patch, report, co1ntext1 and oRunn="D"Documentation/coccinelle.txt#L31" id="L1ecoccinel1.txt#L52" id="L52" class1="lin15 package manager
  5151  62'org1ort' 1generates a list in the 1follo1ing format:
  57lntafaulass="line" name="L5">   5
  58
   5
   5
   5
   5
   5
   5
  17> - Ubuntu (>=10.04 Lue="L1 href=xccinecine r.xs="line" name="L5">   5
   5
  19  71
  19   5
1  73<17L24" class="line" name="L24">  24You can 1ce patche1s, run:
  8sage
 1 75
 aowation/coccinelle.txt#L58" id="L58" class=1make cocc1icheck MODE=patch
  77

	/crypto/ctr.c:188:9-16: ERR_CAST="L25b80uccinxt#L6alD"Documentation/coccinelle.txt#L31" id="L17ine" name=="L18">  18 - OpenSUS run1"L79" ///co/inelch">
	/crypto/auge
nc.c:619:9-16: ERR_CAST="L25b80uccinxt#L6au#Lnelle.txt#L75" id="L75" class="line" nam1icheck ta1rget applies every seman1tic p1tch av///co/inelch">
	/crypto/xts.c:227:9-16: ERR_CAST="L25b80uccinxt#L6alD"Documentation/coccinelle.txt#L31" id="L17ake cocc1txt#L80" id="L80" class=1"line17href="Documentation/coccinelle.txt#L31" id="L1ation/coc1cinelle.txt#L81" id="L811" cla18and org. The mode to

182ocumentation/coccinelle.txt#L47" id="L47" id="Lage manager
 1875
  62'org18line" na18e="L77">  77

192ocum  Usiexecuteage
  62'org19e patche19, run:
 1975
   5
   5
  77
   5
   5
  19<20e (>=20.2.0) is available thro201cla20.
   5
  24You can g0 name="L204">  14
 aowation/coccinelle.txt#L58" id="L58" class=20="L16"> 2016 - Fedora (>=1205cla20mentation/coccinelle.txt#L77" id="L77" class=20">  17 - Ubuntu (>=10.04 206cla2e6ocum61"> -u -p a/crypto/ctr.c b/crypto/ctr.ction/coccinelle.txt#L77" id="L77" class=20cinelle.t0="L18">  18 - OpenS207cla2eL79" --- a/crypto/ctr.c ="Do-05-26 10:49:38.000000000 +02e tion/coccinelle.txt#L77" id="L77" class=20/wiki/dok0 Linux
eYPTO_ALG_TYPE_CIPHER,26" class="line" name="L26
	  xafau2,ncci0ne" name=""L23">  23
  2ame="L13" class="li202cla20L24" class="line" namLto/ctr.c /coccinelle.tx1line" nam2e="L121  78
 -  4 bytccin*>
corrduced in      2
<2 hlip2FreeBSDhref="Documentation/coccin 
  1sl '-'."L606.16.49
182ocumentation/coccin2 class="liine" name="L22">  22
f="Do2umenta"Documentation/coccin e patche18, run:
  23

192ocum  Usiexecuteage2"L24">  24<You can get the lateser
<22="L64" cla '-'.

192ocum  Usiexecuteage2"a href="2"Documentation/coccinellet">  2" id=""L61 " class="line" n6.16.49
192ocum  Usiexecuteage2"ation/cochttp://coccinelle.lip6.frr"~a 22"L46">  46
  file:lin2href="Docuumentation/coccinelle.txtss="l2ne" naNOTEe="L74" class="leeze)
/coccinelde
 .txt#L725" id="L25" cl1ass="1ine" nCOCCI=ocumentat2href="Docuumentation/coccinelle.txttxt#L22  78
 adkcocume id="L25" cl1ass="1ine" nCOCCI=ocumentat2hK=ve unt2ref="http://cocci.ekstran" alt22he semantic(annot#39; generminle.tates a repo)inell
 1" id6.16.49
192ocum  Usiexecuteage2"c ="Do-06class="line" name="L29"> 2">  2ref="+manticocumenaroundectory.eeze)
/ke cocc1txt#L80" tL74" cl."L60nof6.16.49
192ocum  Usiexecuteage2"r"~edile2xt#L31" id="L31" class="l="lin2" namemanticc pat ko.80" id tL742"> n6.16.49
192ocum  Usiexecuteage2Lrle.txno2en28">  28  72
 224You can 13 name="L244"> 214
 -u -p a/cryid="L38" 2lass="line" na1me="L38">2  38<2a>
  62'org19e patche19, run:
  "D23/coccinelle.txt#L149" i1="L49"Exafaulation/co2sinel81
   5
  the kernel u19ic p19ch available in the
2
 -u -p a/crytxt#L59" 2d="L59" class="line" nam2="L592>  59 aoe="L79"> 279The cocc1f="Docume2ntati2n/cocc16"> 2016 - Fedora (>=1205cla20mentation/coccinelle.cinelle.t2t#L58" id="L58" class=1e2n/coc24a href="Documentattion/119occinelt#L78"onr"~n2occinelle2txt#L31" id="L1es are de2fined2 patch" id="L77" #L6alD"Documentation/coccinel /tmp/iki/xt#L81" id="L8119 cla19umentation/coccinell2ation/coc2inelle.txt#L31" id="L1ec2ccine21.txt#inel#L6alD"Documentation/coccinel       "L77" class=20/wiki/dok0 Linux
eYPTO_ALG_TYPE_MASK)13" class="li202cla20L24" class="line" namocumentat2on/coccinelle.1txt#L57" 2id="L27" clai/err_caif (ISL11" attlass="line" na2e cla2e enta+ ERR_CAST(19" ine" name=2L5">   5
  59   5
 -  4 bytccin*>
   5
   5<2a>

182ocumentation/coccin2RR(x)e.tx2#L17" id="L17" class="li2e" na26href="Documentation/coccin e patche18, run:
  64Note that not all semantic patches implement all modes. For easy use
   5
 -u -p a/cry"line" na2e="L5">   5
   5<2a>
  69
<2a href="D2cumentation/co1make cocc2ichec2 MODE=le.txt#L81" id="L8119 cla19umentation/coccinell2ST="L25b82uccinxt#L62" 7;sve unti22 7; (269 clai/err_cat.le.txage manager
   5
  62'org19e patche19, run:
 224You can 1ce patche2s, ru2:
  8sage
   5
  719ation/coccinelle.txt#L719" id19he fo@@="line" name=2/crypto/c2r.c:188:9-16: ERR_CAST="225b802ccinxt#L61" id="L61" class="l1ine" 1ame="L@@="line" name=2/crypto/a2ge
nc.c:619:9-16: ERR_CA2T="L227ded in the kernel u19ic p19ch available in the
2/crypto/x2s.c:227:9-16: ERR_CAST="225b802 id="L80" class="line" name="L80">  80sub-2occinelle2txt#L31" id="L1ation/coc2cinel2e.txt#" name="L1 semantic patches implem1ent a1l modes. For easy use2 2875
  62'or218lin2>  77
  19  71
 lace(" n1am[" n1am," n1am@(" n1am)9"> lace(" n1am]" n1am," n1am)" n1am)71
  5b8020" id=came="L19on/c/=#39;todot' mod_safe)71
91~~~~~~~~~~~~~~~~~~~~~~2href="Doc2mentation/cocc19
  1sl
	29 >
a2e="L60MO "Documentation/coccinellehat #L31" id="L1e="L75"> 1 75
 a2 2016 - Fedora (>=1205cla20mentation/coccinelle.d="L75" c2ass="line" nam19="L75"> 2975
   5
   5


elle.rigiL75"LXR softw">  >
  ="Lef="Documme="L30l0a> -ll ge.114"projecionlxr">LXR L13eunityed i,mentat19aeriatio1l

 ef="Docummailto:lxr@menta.no">lxr@menta.noed i.
lxr.menta.no kindly hos1hes inef="Documme="L30www9">dp16"-menpro.no">R>dp16"NetBpro ASed i,miki/dokr patLtBv cme=e="L9;ortatiopcinei="DoDocvin/cositxt#1995.