Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: cocci <cocci@inria.fr>
Subject: [cocci] strange braces behaviour
Date: Tue, 04 Jun 2024 22:08:33 +0200	[thread overview]
Message-ID: <9c981025522250c68c8cca83a2fa3e32097bae3b.camel@sipsolutions.net> (raw)

Hi,

So I've been trying a few similar things, but today we came across this
one:

Given this function from the current Linux kernel:

void ieee80211_color_change_finish(struct ieee80211_vif *vif, u8 link_id)
{
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
        struct ieee80211_link_data *link;

        if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS))
                return;

        rcu_read_lock();

        link = rcu_dereference(sdata->link[link_id]);
        if (WARN_ON(!link)) {
                rcu_read_unlock();
                return;
        }

        wiphy_work_queue(sdata->local->hw.wiphy,
                         &link->color_change_finalize_work);

        rcu_read_unlock();
}


Applying the following spatch:

@@
identifier func =~ "ieee80211_color_change_finish";
@@
func(...)
{
-...
}


leads to

void ieee80211_color_change_finish(struct ieee80211_vif *vif, u8 link_id)
{
}
}


with
spatch version 1.1.1 compiled with OCaml version 5.0.1+dev0-2022-12-15
and also with
spatch version 1.1.1 compiled with OCaml version 4.14.1


Trying this spatch:

@@
identifier func =~ "ieee80211_color_change_finish";
@@
func(...)
-{...}
+{}


works fine with
spatch version 1.1.1 compiled with OCaml version 5.0.1+dev0-2022-12-15

but *fails* with
spatch version 1.1.1 compiled with OCaml version 4.14.1

saying

EXN: Failure("rule starting on line 1: already tagged token:\nC code
context\nFile \"./test.c\", line 3, column 0, charpos = 76\n  around =
'}',\n  whole content = }") in ./test.c

which is almost stranger than the left-over closing brace, especially
the difference between those two spatch versions I have?


Any thoughts?

(I have a similar situation with removing a whole switch() statement
from the code, but I'll leave that for later)

Thanks,
johannes

             reply	other threads:[~2024-06-04 20:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 20:08 Johannes Berg [this message]
2024-06-04 20:27 ` [cocci] strange braces behaviour Julia Lawall
2024-06-10  6:49 ` Julia Lawall
2024-06-10  6:57   ` Johannes Berg
2024-06-10  7:04     ` Julia Lawall
2024-06-10  9:25       ` Johannes Berg
2024-06-10  9:36         ` Julia Lawall

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=9c981025522250c68c8cca83a2fa3e32097bae3b.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=cocci@inria.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).