[PATCH 1/4] addr2line: Pull show_note() and show_int() in file scope

tbaeder@redhat.com tbaeder@redhat.com
Fri Jan 8 08:13:25 GMT 2021


From: Timm Bäder <tbaeder@redhat.com>

Get rid of the nested functions

Signed-off-by: Timm Bäder <tbaeder@redhat.com>
---
 src/addr2line.c | 47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/src/addr2line.c b/src/addr2line.c
index ea01c1be..34945046 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -598,6 +598,26 @@ get_addr_width (Dwfl_Module *mod)
   return width;
 }
 
+static inline void
+show_note (int (*get) (Dwarf_Line *, bool *),
+	   Dwarf_Line *info,
+	   const char *note)
+{
+  bool flag;
+  if ((*get) (info, &flag) == 0 && flag)
+    fputs (note, stdout);
+}
+
+static inline void
+show_int (int (*get) (Dwarf_Line *, unsigned int *),
+	  Dwarf_Line *info,
+	  const char *name)
+{
+  unsigned int val;
+  if ((*get) (info, &val) == 0 && val != 0)
+    printf (" (%s %u)", name, val);
+}
+
 static int
 handle_address (const char *string, Dwfl *dwfl)
 {
@@ -692,27 +712,12 @@ handle_address (const char *string, Dwfl *dwfl)
 	  Dwarf_Line *info = dwfl_dwarf_line (line, &bias);
 	  assert (info != NULL);
 
-	  inline void show (int (*get) (Dwarf_Line *, bool *),
-			    const char *note)
-	  {
-	    bool flag;
-	    if ((*get) (info, &flag) == 0 && flag)
-	      fputs (note, stdout);
-	  }
-	  inline void show_int (int (*get) (Dwarf_Line *, unsigned int *),
-				const char *name)
-	  {
-	    unsigned int val;
-	    if ((*get) (info, &val) == 0 && val != 0)
-	      printf (" (%s %u)", name, val);
-	  }
-
-	  show (&dwarf_linebeginstatement, " (is_stmt)");
-	  show (&dwarf_lineblock, " (basic_block)");
-	  show (&dwarf_lineprologueend, " (prologue_end)");
-	  show (&dwarf_lineepiloguebegin, " (epilogue_begin)");
-	  show_int (&dwarf_lineisa, "isa");
-	  show_int (&dwarf_linediscriminator, "discriminator");
+	  show_note (&dwarf_linebeginstatement, info, " (is_stmt)");
+	  show_note (&dwarf_lineblock, info, " (basic_block)");
+	  show_note (&dwarf_lineprologueend, info, " (prologue_end)");
+	  show_note (&dwarf_lineepiloguebegin, info, " (epilogue_begin)");
+	  show_int (&dwarf_lineisa, info, "isa");
+	  show_int (&dwarf_linediscriminator, info, "discriminator");
 	}
       putchar ('\n');
     }
-- 
2.26.2



More information about the Elfutils-devel mailing list