* [PATCH v2] scripts/nsdeps: make sure to pass all module source files to spatch
@ 2019-11-05 12:11 Jessica Yu
2019-11-05 12:36 ` Masahiro Yamada
2019-11-05 13:03 ` Matthias Maennich
0 siblings, 2 replies; 3+ messages in thread
From: Jessica Yu @ 2019-11-05 12:11 UTC (permalink / raw)
To: linux-kernel; +Cc: Matthias Maennich, Masahiro Yamada, Jessica Yu
The nsdeps script passes a list of the module source files to
generate_deps_for_ns() as a space delimited string named $mod_source_files,
which then passes it to spatch. But since $mod_source_files is not encased
in quotes, each source file in that string is treated as a separate shell
function argument (as $2, $3, $4, etc.). However, the spatch invocation
only refers to $2, so only the first file out of $mod_source_files is
processed by spatch.
This causes problems (namely, the MODULE_IMPORT_NS() statement doesn't
get inserted) when a module is composed of many source files and the
"main" module file containing the MODULE_LICENSE() statement is not the
first file listed in $mod_source_files. Fix this by encasing
$mod_source_files in quotes so that the entirety of the string is
treated as a single argument and can be referred to as $2.
In addition, put quotes in the variable assignment of mod_source_files
to prevent any shell interpretation and field splitting.
Signed-off-by: Jessica Yu <jeyu@kernel.org>
---
v2: put quotes around mod_source_files variable assignment as suggested by Masahiro.
scripts/nsdeps | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/nsdeps b/scripts/nsdeps
index dda6fbac016e..04cea0921673 100644
--- a/scripts/nsdeps
+++ b/scripts/nsdeps
@@ -31,12 +31,12 @@ generate_deps() {
local mod_file=`echo $@ | sed -e 's/\.ko/\.mod/'`
local ns_deps_file=`echo $@ | sed -e 's/\.ko/\.ns_deps/'`
if [ ! -f "$ns_deps_file" ]; then return; fi
- local mod_source_files=`cat $mod_file | sed -n 1p \
+ local mod_source_files="`cat $mod_file | sed -n 1p \
| sed -e 's/\.o/\.c/g' \
- | sed "s|[^ ]* *|${srctree}/&|g"`
+ | sed "s|[^ ]* *|${srctree}/&|g"`"
for ns in `cat $ns_deps_file`; do
echo "Adding namespace $ns to module $mod_name (if needed)."
- generate_deps_for_ns $ns $mod_source_files
+ generate_deps_for_ns $ns "$mod_source_files"
# sort the imports
for source_file in $mod_source_files; do
sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] scripts/nsdeps: make sure to pass all module source files to spatch
2019-11-05 12:11 [PATCH v2] scripts/nsdeps: make sure to pass all module source files to spatch Jessica Yu
@ 2019-11-05 12:36 ` Masahiro Yamada
2019-11-05 13:03 ` Matthias Maennich
1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2019-11-05 12:36 UTC (permalink / raw)
To: Jessica Yu; +Cc: Linux Kernel Mailing List, Matthias Maennich
On Tue, Nov 5, 2019 at 9:11 PM Jessica Yu <jeyu@kernel.org> wrote:
>
> The nsdeps script passes a list of the module source files to
> generate_deps_for_ns() as a space delimited string named $mod_source_files,
> which then passes it to spatch. But since $mod_source_files is not encased
> in quotes, each source file in that string is treated as a separate shell
> function argument (as $2, $3, $4, etc.). However, the spatch invocation
> only refers to $2, so only the first file out of $mod_source_files is
> processed by spatch.
>
> This causes problems (namely, the MODULE_IMPORT_NS() statement doesn't
> get inserted) when a module is composed of many source files and the
> "main" module file containing the MODULE_LICENSE() statement is not the
> first file listed in $mod_source_files. Fix this by encasing
> $mod_source_files in quotes so that the entirety of the string is
> treated as a single argument and can be referred to as $2.
>
> In addition, put quotes in the variable assignment of mod_source_files
> to prevent any shell interpretation and field splitting.
>
> Signed-off-by: Jessica Yu <jeyu@kernel.org>
> ---
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
> v2: put quotes around mod_source_files variable assignment as suggested by Masahiro.
>
> scripts/nsdeps | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/nsdeps b/scripts/nsdeps
> index dda6fbac016e..04cea0921673 100644
> --- a/scripts/nsdeps
> +++ b/scripts/nsdeps
> @@ -31,12 +31,12 @@ generate_deps() {
> local mod_file=`echo $@ | sed -e 's/\.ko/\.mod/'`
> local ns_deps_file=`echo $@ | sed -e 's/\.ko/\.ns_deps/'`
> if [ ! -f "$ns_deps_file" ]; then return; fi
> - local mod_source_files=`cat $mod_file | sed -n 1p \
> + local mod_source_files="`cat $mod_file | sed -n 1p \
> | sed -e 's/\.o/\.c/g' \
> - | sed "s|[^ ]* *|${srctree}/&|g"`
> + | sed "s|[^ ]* *|${srctree}/&|g"`"
> for ns in `cat $ns_deps_file`; do
> echo "Adding namespace $ns to module $mod_name (if needed)."
> - generate_deps_for_ns $ns $mod_source_files
> + generate_deps_for_ns $ns "$mod_source_files"
> # sort the imports
> for source_file in $mod_source_files; do
> sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp
> --
> 2.16.4
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] scripts/nsdeps: make sure to pass all module source files to spatch
2019-11-05 12:11 [PATCH v2] scripts/nsdeps: make sure to pass all module source files to spatch Jessica Yu
2019-11-05 12:36 ` Masahiro Yamada
@ 2019-11-05 13:03 ` Matthias Maennich
1 sibling, 0 replies; 3+ messages in thread
From: Matthias Maennich @ 2019-11-05 13:03 UTC (permalink / raw)
To: Jessica Yu; +Cc: linux-kernel, Masahiro Yamada
On Tue, Nov 05, 2019 at 01:11:03PM +0100, Jessica Yu wrote:
>The nsdeps script passes a list of the module source files to
>generate_deps_for_ns() as a space delimited string named $mod_source_files,
>which then passes it to spatch. But since $mod_source_files is not encased
>in quotes, each source file in that string is treated as a separate shell
>function argument (as $2, $3, $4, etc.). However, the spatch invocation
>only refers to $2, so only the first file out of $mod_source_files is
>processed by spatch.
>
>This causes problems (namely, the MODULE_IMPORT_NS() statement doesn't
>get inserted) when a module is composed of many source files and the
>"main" module file containing the MODULE_LICENSE() statement is not the
>first file listed in $mod_source_files. Fix this by encasing
>$mod_source_files in quotes so that the entirety of the string is
>treated as a single argument and can be referred to as $2.
>
>In addition, put quotes in the variable assignment of mod_source_files
>to prevent any shell interpretation and field splitting.
>
>Signed-off-by: Jessica Yu <jeyu@kernel.org>
>---
Thanks for fixing this!
Acked-by: Matthias Maennich <maennich@google.com>
Cheers,
Matthias
>
>v2: put quotes around mod_source_files variable assignment as suggested by Masahiro.
>
> scripts/nsdeps | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/scripts/nsdeps b/scripts/nsdeps
>index dda6fbac016e..04cea0921673 100644
>--- a/scripts/nsdeps
>+++ b/scripts/nsdeps
>@@ -31,12 +31,12 @@ generate_deps() {
> local mod_file=`echo $@ | sed -e 's/\.ko/\.mod/'`
> local ns_deps_file=`echo $@ | sed -e 's/\.ko/\.ns_deps/'`
> if [ ! -f "$ns_deps_file" ]; then return; fi
>- local mod_source_files=`cat $mod_file | sed -n 1p \
>+ local mod_source_files="`cat $mod_file | sed -n 1p \
> | sed -e 's/\.o/\.c/g' \
>- | sed "s|[^ ]* *|${srctree}/&|g"`
>+ | sed "s|[^ ]* *|${srctree}/&|g"`"
> for ns in `cat $ns_deps_file`; do
> echo "Adding namespace $ns to module $mod_name (if needed)."
>- generate_deps_for_ns $ns $mod_source_files
>+ generate_deps_for_ns $ns "$mod_source_files"
> # sort the imports
> for source_file in $mod_source_files; do
> sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp
>--
>2.16.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-05 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 12:11 [PATCH v2] scripts/nsdeps: make sure to pass all module source files to spatch Jessica Yu
2019-11-05 12:36 ` Masahiro Yamada
2019-11-05 13:03 ` Matthias Maennich
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).