aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-04-25 13:26:12 +0930
committerAlan Modra <amodra@gmail.com>2023-04-26 10:32:07 +0930
commit5b429b870767e2107bcc7d5d849e04d6901b5912 (patch)
treeb10f21f3cd4d8b0d4694ca33fd94b2fa08d4ea8f
parent9d4f5cabe223b14d56ef6b7d7b5846e8949e3164 (diff)
downloadgdb-5b429b870767e2107bcc7d5d849e04d6901b5912.zip
gdb-5b429b870767e2107bcc7d5d849e04d6901b5912.tar.gz
gdb-5b429b870767e2107bcc7d5d849e04d6901b5912.tar.bz2
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.
-rw-r--r--gas/write.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gas/write.c b/gas/write.c
index 74a00ea..573a667 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;