Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Remove entire multidecl
Date: Thu, 8 Aug 2019 13:01:51 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1908081259010.2995@hadrien> (raw)
In-Reply-To: <7e131616-a0c6-5b59-78b8-a92b569cda27@linbit.com>

[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]



On Thu, 8 Aug 2019, Christoph Böhmwalder wrote:

> So I've looked around in the demos/ and tests/ as well as the documentation,
> but I can't seem to figure out what I'm doing wrong:
>
> test.c
> ------
> int x, y;
>
>
> test.cocci
> ----------
> @@
> identifier x, y;
> @@
> - int x, y;
>
>
> Should be pretty straightforward, but the rule does not match. Is there
> another syntax to use here? In my real use case, I'm trying the same thing
> within a function, and that doesn't match either.
>
> Also, while playing around with it, I found this weird behaviour:
>
> @@
> identifier x, y;
> @@
> - int x;
>
> Yields:
>
> --- test.c
> +++ /tmp/cocci-output-6916-8bc8e1-test.c
> @@ -1 +1 @@
> -int x, y;
> +
>
>
> Not exactly what I expected...

SmPL doesn't support patterns with multiple variable declarations, because
there is really no way to tell whether they will be on one line or
multiple lines.

I'm not sure why the latter is not what you expected.  If you only
expected to remove the int x, then x should not have been an identifier
metavariable.

Basically, it is matching the pattern multiple times on the same code,
once for each variable.  If these matches cause all of the variables to go
away, the type and the ; are removed as well.

It seems that this resulted in adding a blank line.  That is indeed not
really ideal.

julia

>
> Thanks,
> --
> Christoph Böhmwalder
> LINBIT | Keeping the Digital World Running
> DRBD HA —  Disaster Recovery — Software defined Storage
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 10:51 Christoph Böhmwalder
2019-08-08 11:01 ` Julia Lawall [this message]
2019-08-09  6:33   ` Markus Elfring

Reply instructions:

You may reply publically 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.21.1908081259010.2995@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=christoph.boehmwalder@linbit.com \
    --cc=cocci@systeme.lip6.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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox