Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp97602ybx; Wed, 30 Oct 2019 11:56:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCPUvIYW6fAEWOPc4SYOP/T12oH66M0mYF656XVNjR9adVAPdsBvGFBL8N5+lwwdYs/HI3 X-Received: by 2002:a17:906:497:: with SMTP id f23mr1095311eja.234.1572461780603; Wed, 30 Oct 2019 11:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572461780; cv=none; d=google.com; s=arc-20160816; b=M8IEfrgoRdOOIIgieABTiExZ9EISRuE9fPszEFLp+RkqU5AXSWDs5Cx9j8y25ILMlz ccALUINLqgz7byXZFQq4sWjLHWaph28xsi5h7lo1yxP9OtU4GJrh0T6X+1tZ1+JABz1E PSht1NWWXYnmMNYiShnJXa2ac2WYj3Ml8cEnZk/UNofirQ9EBkjou6yurEkHmyxH/qHo ugtRDNZt1h4jk8ARivNJn/GEAKC0JiULRRAUo1DqW7NB3tlADDVa2+VIBi5IZBa8LPqs PMKhCL4k080NM8Y7aVXGRp58EhYSd99uT/2vEOllWncRrV/PApnPhlaMu7tPcAExjESX PZ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qtt0VU3pRFk9rR1OAg8DGlamVQ7Du94kxSTMib2d1Q0=; b=Sf6M7fVD/E1WxVmKXk/zNrrWI/T2a/ypbteYExf3ED6vhlJMO0jpU4sy5drxl7ZqSJ HjiNL7CuciiVPV6OV4+q+8OgfCQljJPkmWBVi8/Cj4YCrdAEatXX2HGzM8phpB2EOJaE /FaxQhfQA7si4NoKz7MCn16HSzZYXaDRnlXwgQpuwjpbDBZUc4RBb2ct9cdVAGd7e3DI rtmBazWRnZHaFO0lW19I49uBpwA4HtwA7eAVvdatsiy4v7EKV+66thQ1DCfcX/rnd5fQ 6zaPd9Zz8BGNS39zLzvn9DDsQtQVE27GkYdTu7M2NV0k47c9kVsW89d+ZJh2rkMYxKki v90Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OOTtj8+F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si2143531edh.14.2019.10.30.11.55.32; Wed, 30 Oct 2019 11:56:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OOTtj8+F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727344AbfJ3QRf (ORCPT + 99 others); Wed, 30 Oct 2019 12:17:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:39938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727330AbfJ3QRe (ORCPT ); Wed, 30 Oct 2019 12:17:34 -0400 Received: from linux-8ccs (unknown [92.117.144.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 29B4D205C9; Wed, 30 Oct 2019 16:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572452253; bh=hPxURatBxOMiOCta6yGik10T9f5u9kgS0G/+XRzfLhU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OOTtj8+FKdg3u6hrgqQmpNIxWoPuPHziziIwXT6SO1EGDdRFVhdLIoalKu0UshqdN gZzc6LVtBNiDfznUvUeJ30SjMBeCBvKNurUZYQTBB0Sr2ZgtA6S64tAWz/+KH3jBnS I5J8zHAgbNs4hjcFYwVdDmyfATyai6w4WyZECt1U= Date: Wed, 30 Oct 2019 17:17:28 +0100 From: Jessica Yu To: Masahiro Yamada Cc: Linux Kernel Mailing List , Matthias Maennich Subject: Re: [PATCH 4/4] scripts/nsdeps: make sure to pass all module source files to spatch Message-ID: <20191030161726.GA13413@linux-8ccs> References: <20191028151427.31612-1-jeyu@kernel.org> <20191028151427.31612-4-jeyu@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-OS: Linux linux-8ccs 4.12.14-lp150.12.28-default x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Masahiro Yamada [29/10/19 21:57 +0900]: >On Tue, Oct 29, 2019 at 12:14 AM 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. >> >> Signed-off-by: Jessica Yu >> --- >> scripts/nsdeps | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/scripts/nsdeps b/scripts/nsdeps >> index 9ddcd5cb96b1..5055b059a81b 100644 >> --- a/scripts/nsdeps >> +++ b/scripts/nsdeps >> @@ -36,7 +36,7 @@ generate_deps() { >> | sed -E "s%(^|\s)([^/][^ ]*)%\1$srctree/\2%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 > >I think this change is correct, but >did you succeed in nsdeps for composite modules >with this patch only? > >I think the following is needed too: > > >diff --git a/scripts/nsdeps b/scripts/nsdeps >index dda6fbac016e..5a23ea616446 100644 >--- a/scripts/nsdeps >+++ b/scripts/nsdeps >@@ -31,9 +31,9 @@ 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 > > >Without this, a module that consists of two files >will be expanded to: > >local mod_source_files=source1.c source2.c Yes, I was able to have nsdeps work for composite modules with just my patch. Without this patch applied, the script produces the following expansion of the generate_deps_for_ns call, (I just added a test namespace MODULE): Adding namespace MODULE to module fs/nfs/nfs.ko. + generate_deps_for_ns MODULE /tmp/ppyu/linux/fs/nfs/client.c /tmp/ppyu/linux/fs/nfs/dir.c /tmp/ppyu/linux/fs/nfs/file.c /tmp/ppyu/linux/fs/nfs/getroot.c /tmp/ppyu/linux/fs/nfs/inode.c /tmp/ppyu/linux/fs/nfs/super.c /tmp/ppyu/linux/fs/nfs/io.c /tmp/ppyu/linux/fs/nfs/direct.c /tmp/ppyu/linux/fs/nfs/pagelist.c /tmp/ppyu/linux/fs/nfs/read.c /tmp/ppyu/linux/fs/nfs/symlink.c /tmp/ppyu/linux/fs/nfs/unlink.c /tmp/ppyu/linux/fs/nfs/write.c /tmp/ppyu/linux/fs/nfs/namespace.c /tmp/ppyu/linux/fs/nfs/mount_clnt.c /tmp/ppyu/linux/fs/nfs/nfstrace.c /tmp/ppyu/linux/fs/nfs/export.c /tmp/ppyu/linux/fs/nfs/sysfs.c /tmp/ppyu/linux/fs/nfs/sysctl.c /tmp/ppyu/linux/fs/nfs/fscache.c /tmp/ppyu/linux/fs/nfs/fscache-index.c + /usr/bin/spatch --very-quiet --in-place --sp-file /tmp/ppyu/linux/scripts/coccinelle/misc/add_namespace.cocci -D ns=MODULE /tmp/ppyu/linux/fs/nfs/client.c So only the first file got included in the spatch invocation. But the spatch call gets fixed with all the files when quotes are added in the call to generate_deps_for_ns. But we need to include your change anyway, to make the script more robust. It would probably prevent more shell script related bugs in the future (Like [1]). I can respin this patch only while the other ones are superceded by your patchset. [1] https://unix.stackexchange.com/a/131767