public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Avoid another -Werror=dangling-pointer
@ 2023-04-26  2:33 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-04-26  2:33 UTC (permalink / raw)
  To: binutils

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 --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;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-26  2:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-26  2:33 Avoid another -Werror=dangling-pointer Alan Modra

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).