From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Avoid another -Werror=dangling-pointer
Date: Wed, 26 Apr 2023 02:35:37 +0000 (GMT) [thread overview]
Message-ID: <20230426023537.DE5C23858425@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5b429b870767e2107bcc7d5d849e04d6901b5912
commit 5b429b870767e2107bcc7d5d849e04d6901b5912
Author: Alan Modra <amodra@gmail.com>
Date: Tue Apr 25 13:26:12 2023 +0930
Avoid another -Werror=dangling-pointer
write.c:415:7: error: dangling pointer ‘prev_frag’ to ‘dummy’ may be used
* write.c (chain_frchains_together_1): Rewrite loop as a do
while to avoid false positive -Wdangling-pointer.
Diff:
---
gas/write.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gas/write.c b/gas/write.c
index 74a00ea97ae..573a667da22 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -380,7 +380,7 @@ chain_frchains_together_1 (segT section, struct frchain *frchp)
fragS dummy, *prev_frag = &dummy;
fixS fix_dummy, *prev_fix = &fix_dummy;
- for (; frchp; frchp = frchp->frch_next)
+ do
{
prev_frag->fr_next = frchp->frch_root;
prev_frag = frchp->frch_last;
@@ -393,7 +393,8 @@ chain_frchains_together_1 (segT section, struct frchain *frchp)
seg_info (section)->fix_tail = frchp->fix_tail;
prev_fix = frchp->fix_tail;
}
- }
+ frchp = frchp->frch_next;
+ } while (frchp);
gas_assert (prev_frag != &dummy
&& prev_frag->fr_type != 0);
prev_frag->fr_next = 0;
reply other threads:[~2023-04-26 2:35 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=20230426023537.DE5C23858425@sourceware.org \
--to=amodra@sourceware.org \
--cc=bfd-cvs@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).