2017-08-10 17:40:40

by Cihangir Akturk

[permalink] [raw]
Subject: [PATCH] coccicheck: improve pattern for getting relative path

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 <[email protected]>
---
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


2017-08-10 19:08:36

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH] coccicheck: improve pattern for getting relative path



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 <[email protected]>
> ---
> 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
>
>

2017-09-22 19:28:37

by Cihangir Akturk

[permalink] [raw]
Subject: Re: [PATCH] coccicheck: improve pattern for getting relative path

On Thu, Aug 10, 2017 at 09:08:31PM +0200, Julia Lawall wrote:
>
>
> 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?

Any comments on this patch? No one has commented yet. But I still get
the same results on current linux-next.

>
> julia
>
> >
> > Signed-off-by: Cihangir Akturk <[email protected]>
> > ---
> > 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
> >
> >

2017-09-23 16:57:59

by Nicolas Palix (LIG)

[permalink] [raw]
Subject: Re: [PATCH] coccicheck: improve pattern for getting relative path

Le 10/08/17 à 19:40, Cihangir Akturk a écrit :
> 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 <[email protected]>

Acked-by: [email protected]
> --- > 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\""
>


--
Nicolas Palix
http://lig-membres.imag.fr/palix/


Attachments:
smime.p7s (2.89 kB)
Signature cryptographique S/MIME