From: Dan Carpenter <error27@gmail.com>
To: linux-sparse@vger.kernel.org
Subject: handling cleanup attributes with a goto
Date: Wed, 3 Jun 2026 11:41:33 +0300 [thread overview]
Message-ID: <ah_ovV_KtDXan8L-@stanley.mountain> (raw)
If you have code like:
for (i = 0; i < 10; i++) {
struct foo *buf __free(kfree) = NULL;
if (frob())
goto one;
one:
blah(); blah(); blah();
if (frob())
goto two;
}
two:
blah(); blah(); blah();
The goto one won't free the buf because the label is inside the block
but the goto two will because it's outside.
At first I thought I could get the scope that the label is in from
the stmt->goto_label->label_scope but that's scope where the goto
can be and not where the label is. Is there a way to get the
information about the scope where the label is?
regards,
dan carpenter
reply other threads:[~2026-06-03 8:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=ah_ovV_KtDXan8L-@stanley.mountain \
--to=error27@gmail.com \
--cc=linux-sparse@vger.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