Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1551763ybg; Thu, 4 Jun 2020 12:36:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZoN30Dv9RGsXaa38RD5WUwI8h7guW97BHE8+CckY7E36QCteo4L2qqvG+8uO4pVVjD4pT X-Received: by 2002:a17:906:6457:: with SMTP id l23mr5108732ejn.188.1591299373186; Thu, 04 Jun 2020 12:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591299373; cv=none; d=google.com; s=arc-20160816; b=IQqIkVe8OxmzJrO8j+mkgoYM8Di9H/51J/9UfeWS+l7E3cnEYnCAdymS+KMRY2yO0Z EMhy7y0C7UiljmOAR63PObEwSoUe9/LmrEXDAZIYN9B7Myi0TJ7tsroxmzItN9nz49so w7NC5pKzcDhyantZOExNZFYvT5tYxSytrAamQpXpeazQsrIz/2p0IOEHpR72Q9cD6wue o8gQFIK34u/5turNs5UNp2HR7g3w+BOwuyNCRHIRplAfuacAbgSw+98+zDwGjrgxDmqS cDoI0cU3Wr1mOqclK1B8qlXhLDl3VX30LLwpPVkgmx5zKFVOTmQK2uotHG0o4DimUtZu U0sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=6UpL37t34qISZOWyjhvQiGB3/BPNqcpfP7VLpoYAxy0=; b=xBWeeS7StE0FkhD5I/yb9XNl0SbH718Lbe86bG2pCLPHI5CQlaY+UmLy0GOiFe6qzw Dyg1XU79LAtirx7reGFOLJL7CHJCas3d03WiauVw1AKACNG8NtA1BGpczYga3Uw7XJmW Hh/pNxh5des7wsX3e/m/M1Fkz2I9yv/hyaYdVbeMWvsmGna4miQz/31vo20kJobmoEep WJ8ImD58FevfLxoTzEt6twSqFcw9xYGQ3m4T5y8jOjxCmaeycaO3N7PJnn0zoutCM0SC /mGm/ylHDvI7aCt84MfDc+E0wSjycXI9EwtcuHmZR25Rs+4nP+jGuCbcfZV/I3GqRSa0 YGcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b101si2317614edf.579.2020.06.04.12.35.50; Thu, 04 Jun 2020 12:36:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728981AbgFDTbZ (ORCPT + 99 others); Thu, 4 Jun 2020 15:31:25 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:56336 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726666AbgFDTbZ (ORCPT ); Thu, 4 Jun 2020 15:31:25 -0400 X-IronPort-AV: E=Sophos;i="5.73,472,1583190000"; d="scan'208";a="350624709" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2020 21:31:22 +0200 Date: Thu, 4 Jun 2020 21:31:21 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Matthias Maennich cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Julia Lawall , YueHaibing , jeyu@kernel.org, cocci@systeme.lip6.fr, stable@vger.kernel.org, Shuah Khan Subject: Re: [PATCH] scripts: add dummy report mode to add_namespace.cocci In-Reply-To: <20200604164145.173925-1-maennich@google.com> Message-ID: References: <20200604164145.173925-1-maennich@google.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Jun 2020, Matthias Maennich wrote: > 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`. > > Suggested-by: Julia Lawall > Fixes: c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed") > Cc: YueHaibing > Cc: jeyu@kernel.org > Cc: cocci@systeme.lip6.fr > Cc: stable@vger.kernel.org > Signed-off-by: Matthias Maennich Acked-by: Julia Lawall Shuah reported the problem to me, so you could add Reported-by: Shuah Khan > --- > scripts/coccinelle/misc/add_namespace.cocci | 8 +++++++- > scripts/nsdeps | 2 +- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/scripts/coccinelle/misc/add_namespace.cocci b/scripts/coccinelle/misc/add_namespace.cocci > index 99e93a6c2e24..cbf1614163cb 100644 > --- a/scripts/coccinelle/misc/add_namespace.cocci > +++ b/scripts/coccinelle/misc/add_namespace.cocci > @@ -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@ > +@@ > diff --git a/scripts/nsdeps b/scripts/nsdeps > index 03a8e7cbe6c7..dab4c1a0e27d 100644 > --- a/scripts/nsdeps > +++ b/scripts/nsdeps > @@ -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 > >