[binutils-gdb] gas: centralize declaration of listing_tail

Jan Beulich jbeulich@sourceware.org
Fri Mar 7 10:29:22 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e83aca0906f40c9dc0cf06dd0b743a5ad4df1ceb

commit e83aca0906f40c9dc0cf06dd0b743a5ad4df1ceb
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Mar 7 11:26:43 2025 +0100

    gas: centralize declaration of listing_tail
    
    Besides it being somewhat off to have three decls scattered across the
    code base, it is generally bad practice for the definition of a symbol
    to not also observe its declaration (making sure the two won't go out of
    sync).

Diff:
---
 gas/config/tc-arm.c | 1 -
 gas/frags.c         | 5 +----
 gas/listing.h       | 2 ++
 gas/read.c          | 1 -
 4 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index ed910b857df..822fd3dabbc 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -3260,7 +3260,6 @@ s_thumb_set (int equiv)
 	 for this symbol.  */
       if (listing & LISTING_SYMBOLS)
 	{
-	  extern struct list_info_struct * listing_tail;
 	  fragS * dummy_frag = (fragS * ) xmalloc (sizeof (fragS));
 
 	  memset (dummy_frag, 0, sizeof (fragS));
diff --git a/gas/frags.c b/gas/frags.c
index d067bb4761e..6684e276189 100644
--- a/gas/frags.c
+++ b/gas/frags.c
@@ -192,10 +192,7 @@ frag_new (size_t old_frags_var_max_size
   frchP->frch_last = frag_now;
 
 #ifndef NO_LISTING
-  {
-    extern struct list_info_struct *listing_tail;
-    frag_now->line = listing_tail;
-  }
+  frag_now->line = listing_tail;
 #endif
 
   gas_assert (frchain_now->frch_last == frag_now);
diff --git a/gas/listing.h b/gas/listing.h
index 791d58410e9..cd4949861a9 100644
--- a/gas/listing.h
+++ b/gas/listing.h
@@ -62,6 +62,8 @@ extern int listing_lhs_width_second;
 extern int listing_lhs_cont_lines;
 extern int listing_rhs_width;
 
+extern struct list_info_struct *listing_tail;
+
 #endif /* __listing_h__ */
 
 /* end of listing.h */
diff --git a/gas/read.c b/gas/read.c
index 2acb4e03a7f..171182d5a0f 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3270,7 +3270,6 @@ assign_symbol (char *name, int mode)
 	 for this symbol.  */
       if (listing & LISTING_SYMBOLS)
 	{
-	  extern struct list_info_struct *listing_tail;
 	  fragS *dummy_frag = notes_calloc (1, sizeof (*dummy_frag));
 	  dummy_frag->line = listing_tail;
 	  dummy_frag->fr_symbol = symbolP;


More information about the Binutils-cvs mailing list