Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1708928 > unrolled thread

[PATCH] coccicheck: improve pattern for getting relative path

Started byCihangir Akturk <cakturk@gmail.com>
First post2017-08-10 19:50 +0200
Last post2017-08-10 21:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] coccicheck: improve pattern for getting relative path Cihangir Akturk <cakturk@gmail.com> - 2017-08-10 19:50 +0200
    Re: [PATCH] coccicheck: improve pattern for getting relative path Julia Lawall <julia.lawall@lip6.fr> - 2017-08-10 21:10 +0200

#1708928 — [PATCH] coccicheck: improve pattern for getting relative path

FromCihangir Akturk <cakturk@gmail.com>
Date2017-08-10 19:50 +0200
Subject[PATCH] coccicheck: improve pattern for getting relative path
Message-ID<ucZKO-jX-21@gated-at.bofh.it>
When invoked with V=1, coccicheck script prints the information about
which semantic patch (*.cocci file) used for this operation.  Actually,
it prints out the relative path of the related semantic patch. The
script uses sed to remove the source tree part from cocci file path like
so:

FILE=`echo $COCCI | sed "s|$srctree/||"`

This pattern works well most of the time. But in cases where $COCCI
doesn't start with "./" characters, it doesn't remove the right part.

Consider the following scenario:

$ make coccicheck COCCI=scripts/coccinelle/api/drm-get-put.cocci \
                        MODE=patch M=drivers/staging V=1

where

COCCI=scripts/coccinelle/api/drm-get-put.cocci and srctree=.

In this case, out pattern matches the first "s/", and we end up
assigning "scriptcoccinelle/api/drm-get-put.cocci" to $FILE.

Fix this by adding a caret ^ at the beginning of regex pattern, so that
it matches only start of the path.

Signed-off-by: Cihangir Akturk <cakturk@gmail.com>
---
 scripts/coccicheck | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccicheck b/scripts/coccicheck
index ec487b8..8de4245 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -193,7 +193,7 @@ coccinelle () {
 
     if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
 
-	FILE=`echo $COCCI | sed "s|$srctree/||"`
+	FILE=`echo $COCCI | sed "s|^$srctree/||"`
 
 	echo "Processing `basename $COCCI`"
 	echo "with option(s) \"$OPT\""
-- 
2.7.4

[toc] | [next] | [standalone]


#1708970

FromJulia Lawall <julia.lawall@lip6.fr>
Date2017-08-10 21:10 +0200
Message-ID<ud10e-1xP-15@gated-at.bofh.it>
In reply to#1708928

On Thu, 10 Aug 2017, Cihangir Akturk wrote:

> When invoked with V=1, coccicheck script prints the information about
> which semantic patch (*.cocci file) used for this operation.  Actually,
> it prints out the relative path of the related semantic patch. The
> script uses sed to remove the source tree part from cocci file path like
> so:
>
> FILE=`echo $COCCI | sed "s|$srctree/||"`
>
> This pattern works well most of the time. But in cases where $COCCI
> doesn't start with "./" characters, it doesn't remove the right part.
>
> Consider the following scenario:
>
> $ make coccicheck COCCI=scripts/coccinelle/api/drm-get-put.cocci \
>                         MODE=patch M=drivers/staging V=1
>
> where
>
> COCCI=scripts/coccinelle/api/drm-get-put.cocci and srctree=.
>
> In this case, out pattern matches the first "s/", and we end up
> assigning "scriptcoccinelle/api/drm-get-put.cocci" to $FILE.
>
> Fix this by adding a caret ^ at the beginning of regex pattern, so that
> it matches only start of the path.

Nicolas, is this ok?

julia

>
> Signed-off-by: Cihangir Akturk <cakturk@gmail.com>
> ---
>  scripts/coccicheck | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/coccicheck b/scripts/coccicheck
> index ec487b8..8de4245 100755
> --- a/scripts/coccicheck
> +++ b/scripts/coccicheck
> @@ -193,7 +193,7 @@ coccinelle () {
>
>      if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
>
> -	FILE=`echo $COCCI | sed "s|$srctree/||"`
> +	FILE=`echo $COCCI | sed "s|^$srctree/||"`
>
>  	echo "Processing `basename $COCCI`"
>  	echo "with option(s) \"$OPT\""
> --
> 2.7.4
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web