mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <julia.lawall@inria.fr>, cocci@inria.fr
Cc: tools@kernel.org, kernel-janitors@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Replacing special goto statements by direct returns?
Date: Tue, 3 Nov 2026 18:48:06 +0100	[thread overview]
Message-ID: <aa076739-d573-43b7-85ad-d2a6e88db1e9@web.de> (raw)
In-Reply-To: <161f567a-f33-7865-8787-844a299ef9c1@inria.fr>

> I think you can do:
> 
> @useful@
> statement S;
> expression error;
> identifier error0;
> position p;
> @@
> 
> S
> error0:@p
>   return error;
> 
> @useless@
> position p1 != useful.p;
> expression error;
> identifier error0;
> @@
> 
> f(...) {
> (
> <...
> - goto error0;
> + return error;
> ...>
> &
> ...
> error0:@p1
>   return error;
> )
> }
> 
> I have not tested this.

This is a pity.


> It might not work,

I got corresponding development concerns.

* You proposed to use a statement variable in the SmPL rule “useful”.
  How safe is the control flow connection to the subsequent code?

* Another metavariable declaration is probably helpful for “f” in the SmPL rule “useless”.


Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci replace_goto_by_return-Julia.cocci
…
minus: parse error: 
  File "replace_goto_by_return-Julia.cocci", line 25, column 2, charpos = 400
  around = '...',
  whole content = & ...


Would you be looking for a better SmPL conjunction?


> or it might be very slow.

I hope that experiences can grow also for more desirable software run time characteristics.

Regards,
Markus

      reply	other threads:[~2026-11-03 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 14:23 Markus Elfring
2026-11-03 16:38 ` Julia Lawall
2026-11-03 17:48   ` Markus Elfring [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=aa076739-d573-43b7-85ad-d2a6e88db1e9@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=julia.lawall@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tools@kernel.org \
    /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

all inboxes | Powered by JetHome®