All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] moving variable declarations up
Date: Wed, 17 Jun 2020 23:15:36 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2006172314450.3083@hadrien> (raw)
In-Reply-To: <812b3a31097815244e0f929552819ac1f119f5a0.camel@sipsolutions.net>



On Wed, 17 Jun 2020, Johannes Berg wrote:

> Hi spatchers,
>
> I've been working on an old code base, and toying with something like
> this:
>
> @@
> type T;
> identifier x;
> expression E, F;
> @@
> {
> +T x;

Change the + to ++

There is no guarantee on the order in which the variables will appear.

> +
>  E;
> ...

Add when any after the ...

julia

> -T x;
> ...
> }
>
> (and also a variant with "T x = F;" where F is an expression).
>
>
> That works OK if there's only a single variable, but...
>
> First, it only moves a single variable up, even if I run it multiple
> times (I think)?
>
> Secondly, sometimes it says something like:
>
> previous modification:
>
>   <<< T x;
>
> CONTEXT
> According to environment 2:
>    rule starting on line 15.x -> id var1
>    rule starting on line 15.T -> u32
>
> current modification:
>
>   <<< T x;
>
> CONTEXT
> According to environment 2:
>    rule starting on line 15.x -> id var2
>    rule starting on line 15.T -> u32
>
> EXN:Failure("rule starting on line 15: already tagged token:\nC code context\nFile \"/tmp/cocci_small_output-170001-6edb7c.c\", line 150, column 4,  charpos = 8969\n    around = 'DEBUG_PRINT', whole content =     DEBUG_PRINT(...omitted...);")
>
>
> That's basically what I saw, something like
>
> DEBUG_PRINT(...);
> u32 var1 = ...;
> u32 var2 = ...;
>
>
> Any ideas how I can make it move more variable declarations up?
>
> Thanks,
> johannes
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply	other threads:[~2020-06-17 21:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 20:54 [Cocci] moving variable declarations up Johannes Berg
2020-06-17 21:15 ` Julia Lawall [this message]
2020-06-17 21:19   ` Johannes Berg
2020-06-17 21:47     ` Johannes Berg
2020-06-18 15:25       ` Julia Lawall
2020-06-18 15:49       ` Julia Lawall
2020-06-18  5:59     ` Julia Lawall
2020-06-18  7:37       ` Johannes Berg
     [not found] <50990ed6-f5b7-c031-a5df-bdaa6863baa8@web.de>
2020-06-18  7:20 ` Johannes Berg
     [not found]   ` <b6ded75b-c4fe-dab6-b50a-d8ce55793b97@web.de>
2020-06-18  7:34     ` Johannes Berg

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.2006172314450.3083@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=johannes@sipsolutions.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.