Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Kees Cook <keescook@chromium.org>
Cc: cocci@inria.fr, Nicolas Palix <nicolas.palix@imag.fr>
Subject: Re: [cocci] Excluding file paths
Date: Mon, 19 Feb 2024 22:31:33 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2402192231180.3358@hadrien> (raw)
In-Reply-To: <202402191324.915AFFD6C2@keescook>



On Mon, 19 Feb 2024, Kees Cook wrote:

> On Mon, Feb 19, 2024 at 10:12:10PM +0100, Julia Lawall wrote:
> >
> >
> > On Mon, 19 Feb 2024, Kees Cook wrote:
> >
> > > Hi!
> > >
> > > I keep running into this, and figured I should just ask: how do I
> > > exclude certain directories (or files) when using "--dir"? For example,
> > > we've been working on removing the ambiguous/fragile C string APIs in
> > > the kernel and replacing them with alternatives, but we can't do this
> > > for userspace programs, since the alternatives only exist in the kernel
> > > code base itself. Mainly, this is about excluding tools/ but there are
> > > also parts of arch/um/ that are built against userspace libraries.
> > >
> > > I tried using "--ignore" but it doesn't seem to work. What's the right
> > > solution here? For example, this trivial replacement:
> >
> > You put the constraint in the initial @@ of the semantic patch.  Try
> >
> > depends on !file in tools && !file in samples
> >
> > Maybe parentheses would b needed, eg !(files in tools)
>
> Thanks! Yes, this works:
>
>
> @scnprintf depends on !(file in "tools") && !(file in "samples")@
> @@
>
> -snprintf
> +scnprintf
>  (...);
>
>
> Now that I know the syntax, I found the part in the docs that
> references "file in":
>
>   The declaration file in checks that the code being processed comes from
>   the mentioned file, or from a subdirectory of the directory to which
>   Coccinelle was applied. In the latter case, the string is matched
>   against the complete pathname. A trailing / is added to the specified
>   subdirectory name, to ensure that a complete subdirectory name is
>   matched.
>
> https://coccinelle.gitlabpages.inria.fr/website/docs/main_grammar.html

Nice that it's useful :)

julia

      parent reply	other threads:[~2024-02-19 21:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <202402191257.843BC9BC@keescook>
2024-02-19 21:12 ` [cocci] Excluding file paths Julia Lawall
     [not found]   ` <202402191324.915AFFD6C2@keescook>
2024-02-19 21:31     ` Julia Lawall [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2402192231180.3358@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=cocci@inria.fr \
    --cc=keescook@chromium.org \
    --cc=nicolas.palix@imag.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).