DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] devtools: don't use bash extension in checkpatches
       [not found] <CGME20180815153249eucas1p2e13cf746fda4b82519b40f3b760a2c33@eucas1p2.samsung.com>
@ 2018-08-15 15:33 ` Ilya Maximets
  2018-08-16  5:25   ` Arnon Warshavsky
  0 siblings, 1 reply; 8+ messages in thread
From: Ilya Maximets @ 2018-08-15 15:33 UTC (permalink / raw)
  To: dev
  Cc: Thomas Monjalon, Arnon Warshavsky, Stephen Hemminger,
	Ilya Maximets, stable

'read -d' is a bash extension and doesn't work in POSIX shells.
For example 'checkpatches.sh' doesn't work properly on ubuntu,
where 'dash' is a default shell:

  ./devtools/checkpatches.sh: 52: read: Illegal option -d

Let's use single quotes instead of variable.

Fixes: 7413e7f2aeb3 ("devtools: alert on new calls to exit from libs")
CC: stable@dpdk.org

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 devtools/checkpatches.sh | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index ba795ad1d..aad35275c 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -44,12 +44,18 @@ print_usage () {
 }
 
 check_forbidden_additions() {
-    # This awk script receives a list of expressions to monitor
-    # and a list of folders to search these expressions in
-    # - No search is done inside comments
-    # - Both additions and removals of the expressions are checked
-    #   A positive balance of additions fails the check
-	read -d '' awk_script << 'EOF'
+	# This awk script receives a list of expressions to monitor
+	# and a list of folders to search these expressions in
+	# - No search is done inside comments
+	# - Both additions and removals of the expressions are checked
+	#   A positive balance of additions fails the check
+	# ---------------------------------
+	# refrain from new additions of rte_panic() and rte_exit()
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib drivers" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		-v RET_ON_FAIL=1 \
+	'
 	BEGIN {
 		split(FOLDERS,deny_folders," ");
 		split(EXPRESSIONS,deny_expr," ");
@@ -70,7 +76,7 @@ check_forbidden_additions() {
 		# non comment code
 		if (in_comment == 0) {
 			for (i in deny_expr) {
-				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_added = "^+.*" deny_expr[i];
 				forbidden_removed="^-.*" deny_expr[i];
 				current = expressions[deny_expr[i]]
 				if ($0 ~ forbidden_added) {
@@ -90,13 +96,13 @@ check_forbidden_additions() {
 	}
 	# switch to next file , check if the balance of add/remove
 	# of previous filehad new additions
-	($0 ~ "^\+\+\+ b/") {
+	($0 ~ "^+++ b/") {
 		in_file = 0;
 		if (count > 0) {
 			exit;
 		}
 		for (i in deny_folders) {
-			re = "^\+\+\+ b/" deny_folders[i];
+			re = "^+++ b/" deny_folders[i];
 			if ($0 ~ deny_folders[i]) {
 				in_file = 1
 				last_file = $0
@@ -114,15 +120,7 @@ check_forbidden_additions() {
 			}
 			exit RET_ON_FAIL
 		}
-	}
-EOF
-	# ---------------------------------
-	# refrain from new additions of rte_panic() and rte_exit()
-	# multiple folders and expressions are separated by spaces
-	awk -v FOLDERS="lib drivers" \
-		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
-		-v RET_ON_FAIL=1 \
-		"$awk_script" -
+	}' -
 }
 
 number=0
-- 
2.17.1

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

* Re: [dpdk-dev] [PATCH] devtools: don't use bash extension in checkpatches
  2018-08-15 15:33 ` [dpdk-dev] [PATCH] devtools: don't use bash extension in checkpatches Ilya Maximets
@ 2018-08-16  5:25   ` Arnon Warshavsky
  2018-09-14 14:50     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
  0 siblings, 1 reply; 8+ messages in thread
From: Arnon Warshavsky @ 2018-08-16  5:25 UTC (permalink / raw)
  To: Ilya Maximets; +Cc: dev, Thomas Monjalon, Stephen Hemminger, stable

Hi Ilya

Let's use single quotes instead of variable.


Using the script directly with single quotes loses the ability to reuse it
with an additional set of folders , expressions and RET_ON_FAIL.
If we wish to keep the awk code in this file and not in a separate file,
maybe receiving the awk script parameters from the function
 check_forbidden_additions( ) can also preserve the ability to reuse in
future cases.

thanks
/Arnon

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
  2018-08-16  5:25   ` Arnon Warshavsky
@ 2018-09-14 14:50     ` Thomas Monjalon
  2018-09-14 15:10       ` Ilya Maximets
  2018-09-15 19:07       ` Arnon Warshavsky
  0 siblings, 2 replies; 8+ messages in thread
From: Thomas Monjalon @ 2018-09-14 14:50 UTC (permalink / raw)
  To: Arnon Warshavsky; +Cc: Ilya Maximets, dev, Stephen Hemminger

16/08/2018 07:25, Arnon Warshavsky:
> Hi Ilya
> 
> Let's use single quotes instead of variable.
> 
> 
> Using the script directly with single quotes loses the ability to reuse it
> with an additional set of folders , expressions and RET_ON_FAIL.

I don't know awk. Please could you explain what we are loosing and why?

> If we wish to keep the awk code in this file and not in a separate file,
> maybe receiving the awk script parameters from the function
>  check_forbidden_additions( ) can also preserve the ability to reuse in
> future cases.

Yes I feel we could add some parameters to this function.
And yes, we could move the awk script in a separate file.
Actually, it would be better to keep checkpatches.sh as a wrapper script
calling various tools.

Thanks

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
  2018-09-14 14:50     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
@ 2018-09-14 15:10       ` Ilya Maximets
  2018-09-15 21:07         ` Thomas Monjalon
  2018-09-15 19:07       ` Arnon Warshavsky
  1 sibling, 1 reply; 8+ messages in thread
From: Ilya Maximets @ 2018-09-14 15:10 UTC (permalink / raw)
  To: Thomas Monjalon, Arnon Warshavsky
  Cc: dev, Stephen Hemminger, Andrzej Ostruszka

Hi Thomas.

Beside your questions,
There is another patch that targeted to fix this issue:
	http://patches.dpdk.org/patch/44020/
And one similar to mine that I missed while sending:
	http://patches.dpdk.org/patch/43692/

So, I'm not sure which one should be accepted and if I need to
update my version. What do you think? Stephen? Andrzej?

Best regards, Ilya Maximets.

On 14.09.2018 17:50, Thomas Monjalon wrote:
> 16/08/2018 07:25, Arnon Warshavsky:
>> Hi Ilya
>>
>> Let's use single quotes instead of variable.
>>
>>
>> Using the script directly with single quotes loses the ability to reuse it
>> with an additional set of folders , expressions and RET_ON_FAIL.
> 
> I don't know awk. Please could you explain what we are loosing and why?
> 
>> If we wish to keep the awk code in this file and not in a separate file,
>> maybe receiving the awk script parameters from the function
>>  check_forbidden_additions( ) can also preserve the ability to reuse in
>> future cases.
> 
> Yes I feel we could add some parameters to this function.
> And yes, we could move the awk script in a separate file.
> Actually, it would be better to keep checkpatches.sh as a wrapper script
> calling various tools.
> 
> Thanks
> 
> 
> 
> 

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
  2018-09-14 14:50     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
  2018-09-14 15:10       ` Ilya Maximets
@ 2018-09-15 19:07       ` Arnon Warshavsky
  2018-09-15 20:37         ` Thomas Monjalon
  1 sibling, 1 reply; 8+ messages in thread
From: Arnon Warshavsky @ 2018-09-15 19:07 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Ilya Maximets, dev, Stephen Hemminger

> HI
> >
> > Let's use single quotes instead of variable.
> >
> >
> > Using the script directly with single quotes loses the ability to reuse
> it
> > with an additional set of folders , expressions and RET_ON_FAIL.
>
> I don't know awk. Please could you explain what we are loosing and why?
>
The awk script was written with intention to be called with future optional
various folders and banned expressions.
The optional reuse takes place inside the function  check_forbidden_additions(
)
with  different instances passed to the awk script that is loaded using the
apparently unfriendly -d.
(currently only rte_panic)
If we move the parameters to the outer function, i.e
check_forbidden_additions(
params ...)
then there is no problem calling the awk script with single quotes

>
> > If we wish to keep the awk code in this file and not in a separate file,
> > maybe receiving the awk script parameters from the function
> >  check_forbidden_additions( ) can also preserve the ability to reuse in
> > future cases.
>
> Yes I feel we could add some parameters to this function.
> And yes, we could move the awk script in a separate file.
> Actually, it would be better to keep checkpatches.sh as a wrapper script
> calling various tools.
>
I was under the wrong impression the  opposite was desired, so yes,
moving the entire awk code to a separate file would indeed be the cleanest.

thanks
/Arnon

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
  2018-09-15 19:07       ` Arnon Warshavsky
@ 2018-09-15 20:37         ` Thomas Monjalon
  2018-09-16  3:13           ` Arnon Warshavsky
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Monjalon @ 2018-09-15 20:37 UTC (permalink / raw)
  To: Arnon Warshavsky; +Cc: Ilya Maximets, dev, Stephen Hemminger

15/09/2018 21:07, Arnon Warshavsky:
> > > If we wish to keep the awk code in this file and not in a separate file,
> > > maybe receiving the awk script parameters from the function
> > >  check_forbidden_additions( ) can also preserve the ability to reuse in
> > > future cases.
> >
> > Yes I feel we could add some parameters to this function.
> > And yes, we could move the awk script in a separate file.
> > Actually, it would be better to keep checkpatches.sh as a wrapper script
> > calling various tools.
> >
> I was under the wrong impression the  opposite was desired, so yes,
> moving the entire awk code to a separate file would indeed be the cleanest.

OK, who can do this change please?

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
  2018-09-14 15:10       ` Ilya Maximets
@ 2018-09-15 21:07         ` Thomas Monjalon
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2018-09-15 21:07 UTC (permalink / raw)
  To: Ilya Maximets; +Cc: Arnon Warshavsky, dev, Stephen Hemminger, Andrzej Ostruszka

14/09/2018 17:10, Ilya Maximets:
> Hi Thomas.
> 
> Beside your questions,
> There is another patch that targeted to fix this issue:
> 	http://patches.dpdk.org/patch/44020/
> And one similar to mine that I missed while sending:
> 	http://patches.dpdk.org/patch/43692/
> 
> So, I'm not sure which one should be accepted and if I need to
> update my version. What do you think? Stephen? Andrzej?

Generally speaking, I think it's better to avoid bash extensions
and comply with POSIX. That's why I support the proposal of moving
the awk script in its own file, removing the need for "read -d".

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH] devtools: don't use bash extension in checkpatches
  2018-09-15 20:37         ` Thomas Monjalon
@ 2018-09-16  3:13           ` Arnon Warshavsky
  0 siblings, 0 replies; 8+ messages in thread
From: Arnon Warshavsky @ 2018-09-16  3:13 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Ilya Maximets, dev, Stephen Hemminger

> > I was under the wrong impression the  opposite was desired, so yes,
> > moving the entire awk code to a separate file would indeed be the
> cleanest.
>
> OK, who can do this change please?
>
>
> I will do the move to a different file later on this week
thanks
/Arnon

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

end of thread, other threads:[~2018-09-16  3:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180815153249eucas1p2e13cf746fda4b82519b40f3b760a2c33@eucas1p2.samsung.com>
2018-08-15 15:33 ` [dpdk-dev] [PATCH] devtools: don't use bash extension in checkpatches Ilya Maximets
2018-08-16  5:25   ` Arnon Warshavsky
2018-09-14 14:50     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2018-09-14 15:10       ` Ilya Maximets
2018-09-15 21:07         ` Thomas Monjalon
2018-09-15 19:07       ` Arnon Warshavsky
2018-09-15 20:37         ` Thomas Monjalon
2018-09-16  3:13           ` Arnon Warshavsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).