Skip to contentSkip to conversation

scripts: add dummy report mode to add_namespace.cocci

PATCH In review Matthias Maennich 4 participants 11 messages Jun 4, 2020 – Aug 6, 2020

Subsystems (3)
lore
Share & tools
lore

Matthias Maennich

author maintainer
#0 lore raw

PATCH 1/1 scripts: add dummy report mode to add_namespace.cocci

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough make nsdeps.

Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>
---
 scripts/coccinelle/misc/add_namespace.cocci | 8 +++++++-
 scripts/nsdeps                              | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
scripts/coccinelle/misc/add_namespace.cocci +7 -1
index 99e93a6c2e24..cbf1614163cb 100644
@@ -6,6 +6,7 @@
 /// add a missing namespace tag to a module source file.
 ///
 
+virtual nsdeps
 virtual report
 
 @has_ns_import@
@@ -16,10 +17,15 @@ MODULE_IMPORT_NS(ns);
 
 // Add missing imports, but only adjacent to a MODULE_LICENSE statement.
 // That ensures we are adding it only to the main module source file.
-@do_import depends on !has_ns_import@
+@do_import depends on !has_ns_import && nsdeps@
 declarer name MODULE_LICENSE;
 expression license;
 identifier virtual.ns;
 @@
 MODULE_LICENSE(license);
 + MODULE_IMPORT_NS(ns);
+
+// Dummy rule for report mode that would otherwise be empty and make spatch
+// fail ("No rules apply.")
+@script:python depends on report@
+@@
scripts/nsdeps +1 -1
index 03a8e7cbe6c7..dab4c1a0e27d 100644
@@ -29,7 +29,7 @@ fi
 
 generate_deps_for_ns() {
 	$SPATCH --very-quiet --in-place --sp-file \
-		$srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2
+		$srctree/scripts/coccinelle/misc/add_namespace.cocci -D nsdeps -D ns=$1 $2
 }
 
 generate_deps() {
Signature · 1 line
2.27.0.rc2.251.g90737beb825-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>

Shuah reported the problem to me, so you could add

Quoted 51 lines
---
 scripts/coccinelle/misc/add_namespace.cocci | 8 +++++++-
 scripts/nsdeps                              | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
scripts/coccinelle/misc/add_namespace.cocci +7 -1
index 99e93a6c2e24..cbf1614163cb 100644
@@ -6,6 +6,7 @@
 /// add a missing namespace tag to a module source file.
 ///
 
+virtual nsdeps
 virtual report
 
 @has_ns_import@
@@ -16,10 +17,15 @@ MODULE_IMPORT_NS(ns);
 
 // Add missing imports, but only adjacent to a MODULE_LICENSE statement.
 // That ensures we are adding it only to the main module source file.
-@do_import depends on !has_ns_import@
+@do_import depends on !has_ns_import && nsdeps@
 declarer name MODULE_LICENSE;
 expression license;
 identifier virtual.ns;
 @@
 MODULE_LICENSE(license);
 + MODULE_IMPORT_NS(ns);
+
+// Dummy rule for report mode that would otherwise be empty and make spatch
+// fail ("No rules apply.")
+@script:python depends on report@
+@@
scripts/nsdeps +1 -2
index 03a8e7cbe6c7..dab4c1a0e27d 100644
@@ -29,7 +29,7 @@ fi
 
 generate_deps_for_ns() {
 	$SPATCH --very-quiet --in-place --sp-file \
-		$srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2
+		$srctree/scripts/coccinelle/misc/add_namespace.cocci -D nsdeps -D ns=$1 $2
 }
 
 generate_deps() {
--

2.27.0.rc2.251.g90737beb825-goog

#2 lore raw
Quoted 28 lines · Julia Lawall
Quoted 16 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>
Quoted 6 lines

Shuah reported the problem to me, so you could add

Very cool. No errors with this patch. Thanks for fixing it quickly.

thanks,
-- Shuah

author maintainer
#3 lore raw
Quoted 31 lines · Shuah Khan
Quoted 30 lines · Julia Lawall
Quoted 16 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>
Quoted 7 lines
Quoted 4 lines

Shuah reported the problem to me, so you could add

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Is somebody willing to take this patch through their tree?

Cheers,
Matthias

Quoted 6 lines

thanks,
-- Shuah

maintainer
#4 lore raw
Quoted 34 lines · Matthias Maennich
Quoted 33 lines · Shuah Khan
Quoted 32 lines · Julia Lawall
Quoted 16 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Yes, that would be fine.

julia

Quoted 13 lines

Is somebody willing to take this patch through their tree?

Cheers,
Matthias

Quoted 6 lines

thanks,
-- Shuah

Tested-by
#5 lore raw
In reply to Matthias Maennich
Quoted 34 lines · Matthias Maennich
Quoted 33 lines · Shuah Khan
Quoted 32 lines · Julia Lawall
Quoted 16 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Yes

Quoted 3 lines

Is somebody willing to take this patch through their tree?

My guess is that these go through kbuild git??

thanks,
-- Shuah

#6 lore raw
Quoted 48 lines · Shuah Khan
Quoted 38 lines · Matthias Maennich
Quoted 37 lines · Shuah Khan
Quoted 36 lines · Julia Lawall
Quoted 20 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and
replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule,
as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up
with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough
make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Quoted 8 lines

Yes

Quoted 3 lines

Is somebody willing to take this patch through their tree?

My guess is that these go through kbuild git??

If you want to take this, that's fine with me. But as I had the original file come through my tree, I can take it too. It's up to you, either is ok with me.

thanks

greg k-h

#7 lore raw
Quoted 53 lines · Greg Kroah-Hartman
Quoted 52 lines · Shuah Khan
Quoted 38 lines · Matthias Maennich
Quoted 37 lines · Shuah Khan
Quoted 36 lines · Julia Lawall
Quoted 20 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and
replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule,
as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up
with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough
make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Yes

Quoted 1 line
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Is somebody willing to take this patch through their tree?

My guess is that these go through kbuild git??

If you want to take this, that's fine with me. But as I had the original file come through my tree, I can take it too. It's up to you, either is ok with me.

Great. Please take this through your tree.

thanks,
-- Shuah

#8 lore raw
Quoted 57 lines · Shuah Khan
Quoted 56 lines · Greg Kroah-Hartman
Quoted 55 lines · Shuah Khan
Quoted 38 lines · Matthias Maennich
Quoted 37 lines · Shuah Khan
Quoted 36 lines · Julia Lawall
Quoted 20 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and
replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule,
as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up
with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough
make nsdeps.

Quoted 7 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed")
Cc YueHaibing <[email protected]>

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Yes

Quoted 3 lines

Is somebody willing to take this patch through their tree?

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

My guess is that these go through kbuild git??

If you want to take this, that's fine with me.  But as I had the original file come through my tree, I can take it too.  It's up to you, either is ok with me.

Great. Please take this through your tree.

Greg! Looks like this one didn't make it in. Can you pick this up?

thanks,
-- Shuah

#9 lore raw
Quoted 67 lines · Shuah Khan
Quoted 66 lines · Shuah Khan
Quoted 64 lines · Greg Kroah-Hartman
Quoted 50 lines · Shuah Khan
Quoted 40 lines · Matthias Maennich
Quoted 39 lines · Shuah Khan
Quoted 38 lines · Julia Lawall
Quoted 21 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and
replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule,
as otherwise it errors out with "No rules
apply". Using a script:python
rule appears unrelated and odd, but this is the shortest I could come up
with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough
make nsdeps.

Quoted 8 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace:

Fix coccicheck failed")

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Quoted 8 lines

Yes

Quoted 3 lines

Is somebody willing to take this patch through their tree?

My guess is that these go through kbuild git??

If you want to take this, that's fine with me.  But as I had the original file come through my tree, I can take it too.  It's up to you, either is ok with me.

Quoted 4 lines
Quoted 2 lines

Great. Please take this through your tree.

Greg! Looks like this one didn't make it in. Can you pick this up?

I think this is 55c7549819e4 ("scripts: add dummy report mode to add_namespace.cocci") in Linus's tree right now, right?

thanks,

greg k-h

#10 lore raw
Quoted 68 lines · Greg Kroah-Hartman
Quoted 67 lines · Shuah Khan
Quoted 66 lines · Shuah Khan
Quoted 64 lines · Greg Kroah-Hartman
Quoted 50 lines · Shuah Khan
Quoted 40 lines · Matthias Maennich
Quoted 39 lines · Shuah Khan
Quoted 38 lines · Julia Lawall
Quoted 21 lines · Matthias Maennich

When running make coccicheck in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set.

In order to fix that, add the virtual rule nsdeps and only do search and
replace if that rule has been explicitly requested.

In order to make spatch happy in report mode, we also need a dummy rule,
as otherwise it errors out with "No rules
apply". Using a script:python
rule appears unrelated and odd, but this is the shortest I could come up
with.

Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough
make nsdeps.

Quoted 8 lines
Fixes c7c4e29fb5a4 ("scripts: add_namespace:

Fix coccicheck failed")

Shuah reported the problem to me, so you could add

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Very cool. No errors with this patch. Thanks for fixing it quickly.

I am happy I could fix that and thanks for confirming. I assume your Tested-by could be added?

Quoted 8 lines

Yes

Quoted 3 lines

Is somebody willing to take this patch through their tree?

My guess is that these go through kbuild git??

If you want to take this, that's fine with me.  But as I had the original file come through my tree, I can take it too.  It's up to you, either is ok with me.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Great. Please take this through your tree.

Greg! Looks like this one didn't make it in. Can you pick this up?

I think this is 55c7549819e4 ("scripts: add dummy report mode to add_namespace.cocci") in Linus's tree right now, right?

Yes. It is in Linux 5.9. I was looking in the wrong place on Linux 5.8. :(

thanks,
-- Shuah