Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] [PATCH v7] coccicheck: Support search for SmPL scripts within selected directory hierarchy
@ 2019-11-11  7:42 zhongshiqi
  2019-11-11 18:45 ` [Cocci] [v7] " Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: zhongshiqi @ 2019-11-11  7:42 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: wang.yi59, michal.lkml, corbet, linux-doc, nicolas.palix,
	linux-kernel, xue.zhihong, cheng.shengyu, zhongshiqi, cocci

*Allow defining the environment variable “COCCI” as a directory to
 search SmPL scripts.

*Start a corresponding file determination if it contains an acceptable
 path.

*Adjust software documentation for using coccicheck with
 a selected directory.

Signed-off-by: zhongshiqi <zhong.shiqi@zte.com.cn>
---
Changes in v7:
        1:adjust coccinelle.rst documentation
        2:fix a repo of "default"

Changes in v6:
        update coccinelle.rst documents and add instructions for use this

Changes in v5:
        rewrite change description as an enumeration

Changes in v4:
        rewrite change description in another wording

Changes in v3:
        1:rewrite change description
        2:fix patch subject
        3:modify commit log

Changes in v2:
        1.fix patch subject according to the reply by Markus
        <Markus.Elfring@web.de>
        2.change description in “imperative mood”

---
 Documentation/dev-tools/coccinelle.rst | 69 +++++++++++++++++++++-------------
 scripts/coccicheck                     |  4 ++
 2 files changed, 47 insertions(+), 26 deletions(-)

diff --git a/Documentation/dev-tools/coccinelle.rst b/Documentation/dev-tools/coccinelle.rst
index 00a3409..90abe21 100644
--- a/Documentation/dev-tools/coccinelle.rst
+++ b/Documentation/dev-tools/coccinelle.rst
@@ -100,8 +100,8 @@ Two other modes provide some common combinations of these modes.
   It should be used with the C option (described later)
   which checks the code on a file basis.
 
-Examples
-~~~~~~~~
+Using Coccinelle with the default configuration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 To make a report for every semantic patch, run the following command::
 
@@ -127,41 +127,36 @@ To enable verbose messages set the V= variable, for example::
 
    make coccicheck MODE=report V=1
 
-Coccinelle parallelization
----------------------------
+Using Coccinelle with a single file selection
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-By default, coccicheck tries to run as parallel as possible. To change
-the parallelism, set the J= variable. For example, to run across 4 CPUs::
+The optional make variable COCCI can be used to check a single
+semantic patch. In that case, the variable must be initialized with
+the name of the semantic patch to apply.
 
-   make coccicheck MODE=report J=4
+For instance::
 
-As of Coccinelle 1.0.2 Coccinelle uses Ocaml parmap for parallelization,
-if support for this is detected you will benefit from parmap parallelization.
+	make coccicheck COCCI=<my_SP.cocci> MODE=patch
 
-When parmap is enabled coccicheck will enable dynamic load balancing by using
-``--chunksize 1`` argument, this ensures we keep feeding threads with work
-one by one, so that we avoid the situation where most work gets done by only
-a few threads. With dynamic load balancing, if a thread finishes early we keep
-feeding it more work.
+or::
 
-When parmap is enabled, if an error occurs in Coccinelle, this error
-value is propagated back, the return value of the ``make coccicheck``
-captures this return value.
+	make coccicheck COCCI=<my_SP.cocci> MODE=report
 
-Using Coccinelle with a single semantic patch
----------------------------------------------
 
-The optional make variable COCCI can be used to check a single
-semantic patch. In that case, the variable must be initialized with
-the name of the semantic patch to apply.
+Using Coccinelle with directory selection
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The optional make variable COCCI can be used to search semantic patch in a
+directory. In that case, the variable must be initialized with the name of
+a directory which contains semantic patches.
 
 For instance::
 
-	make coccicheck COCCI=<my_SP.cocci> MODE=patch
+	make coccicheck COCCI=<my_SPDIR> MODE=patch
 
 or::
 
-	make coccicheck COCCI=<my_SP.cocci> MODE=report
+	make coccicheck COCCI=<my_SPDIR> MODE=report
 
 
 Controlling Which Files are Processed by Coccinelle
@@ -187,12 +182,34 @@ In these modes, which works on a file basis, there is no information
 about semantic patches displayed, and no commit message proposed.
 
 This runs every semantic patch in scripts/coccinelle by default. The
-COCCI variable may additionally be used to only apply a single
-semantic patch as shown in the previous section.
+COCCI variable may additionally be used to apply a single semantic
+patch or a directory which contains semantic patches as shown in the
+previous section.
 
 The "report" mode is the default. You can select another one with the
 MODE variable explained above.
 
+Coccinelle parallelization
+--------------------------
+
+By default, coccicheck tries to run as parallel as possible. To change
+the parallelism, set the J= variable. For example, to run across 4 CPUs::
+
+   make coccicheck MODE=report J=4
+
+As of Coccinelle 1.0.2 Coccinelle uses Ocaml parmap for parallelization,
+if support for this is detected you will benefit from parmap parallelization.
+
+When parmap is enabled coccicheck will enable dynamic load balancing by using
+``--chunksize 1`` argument, this ensures we keep feeding threads with work
+one by one, so that we avoid the situation where most work gets done by only
+a few threads. With dynamic load balancing, if a thread finishes early we keep
+feeding it more work.
+
+When parmap is enabled, if an error occurs in Coccinelle, this error
+value is propagated back, the return value of the ``make coccicheck``
+captures this return value.
+
 Debugging Coccinelle SmPL patches
 ---------------------------------
 
diff --git a/scripts/coccicheck b/scripts/coccicheck
index e04d328..e64a22e 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -257,6 +257,10 @@ if [ "$COCCI" = "" ] ; then
     for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
 	coccinelle $f
     done
+elif [ -d "$COCCI" ] ; then
+    for f in `find $COCCI/ -name '*.cocci' -type f | sort`; do
+    coccinelle $f
+    done
 else
     coccinelle $COCCI
 fi
-- 
2.9.5

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Cocci] [v7] coccicheck: Support search for SmPL scripts within selected directory hierarchy
  2019-11-11  7:42 [Cocci] [PATCH v7] coccicheck: Support search for SmPL scripts within selected directory hierarchy zhongshiqi
@ 2019-11-11 18:45 ` " Markus Elfring
  2019-11-12  1:06   ` [Cocci] [v7] coccicheck: Support search for SmPL scripts within selecteddirectory hierarchy zhong.shiqi
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2019-11-11 18:45 UTC (permalink / raw)
  To: Zhong Shiqi, cocci, linux-doc
  Cc: Yi Wang, Michal Marek, Jonathan Corbet, Nicolas Palix,
	kernel-janitors, linux-kernel, Xue Zhihong, Cheng Shengyu

> Changes in v7:
>         1:adjust coccinelle.rst documentation

Thanks for your contribution.

Now I am curious if other contributors will add corresponding review comments.


>         2:fix a repo of "default"

I find the word “repo” partly unclear at the moment.

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Cocci] [v7] coccicheck: Support search for SmPL scripts within selecteddirectory hierarchy
  2019-11-11 18:45 ` [Cocci] [v7] " Markus Elfring
@ 2019-11-12  1:06   ` zhong.shiqi
  0 siblings, 0 replies; 3+ messages in thread
From: zhong.shiqi @ 2019-11-12  1:06 UTC (permalink / raw)
  To: Markus.Elfring
  Cc: wang.yi59, corbet, michal.lkml, nicolas.palix, linux-doc,
	kernel-janitors, linux-kernel, xue.zhihong, cheng.shengyu, cocci

[-- Attachment #1.1: Type: text/plain, Size: 369 bytes --]

> > Changes in v7:
> >         1:adjust coccinelle.rst documentation
> 
> Thanks for your contribution.
> 
> Now I am curious if other contributors will add corresponding review comments.
> 
> 
> >         2:fix a repo of "default" 

    Sorry...it should be "typo".

Thanks
Zhong.shiqi

> I find the word “repo” partly unclear at the moment.
> 
> Regards,
> Markus

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11  7:42 [Cocci] [PATCH v7] coccicheck: Support search for SmPL scripts within selected directory hierarchy zhongshiqi
2019-11-11 18:45 ` [Cocci] [v7] " Markus Elfring
2019-11-12  1:06   ` [Cocci] [v7] coccicheck: Support search for SmPL scripts within selecteddirectory hierarchy zhong.shiqi

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git