[PATCH 05/14] segment_report_module: Pull finish_portion() info file scope

Timm Bäder tbaeder@redhat.com
Thu Nov 12 15:04:03 GMT 2020


Signed-off-by: Timm Bäder <tbaeder@redhat.com>
---
 libdwfl/dwfl_segment_report_module.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index ba11b60a..751a96f1 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -242,6 +242,18 @@ segment_read (Dwfl *dwfl,
                                addr, minread, memory_callback_arg);
 }
 
+
+static inline void
+finish_portion (Dwfl *dwfl,
+                Dwfl_Memory_Callback *memory_callback,
+                void *memory_callback_arg,
+                void **data, size_t *data_size)
+{
+  if (*data_size != 0 && *data != NULL)
+    (void) segment_read (dwfl, memory_callback, memory_callback_arg,
+                         -1, data, data_size, 0, 0);
+}
+
 int
 dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 			    Dwfl_Memory_Callback *memory_callback,
@@ -309,13 +321,6 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
     return false;
   }
 
-  inline void finish_portion (void **data, size_t *data_size)
-  {
-    if (*data_size != 0 && *data != NULL)
-      (void) segment_read (dwfl, memory_callback, memory_callback_arg,
-                           -1, data, data_size, 0, 0);
-  }
-
   /* Extract the information we need from the file header.  */
   const unsigned char *e_ident;
   unsigned char ei_class;
@@ -522,7 +527,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
   done:
     if (notes != data)
       free (notes);
-    finish_portion (&data, &data_size);
+    finish_portion (dwfl, memory_callback, memory_callback_arg, &data, &data_size);
   }
 
   /* Consider each of the program headers we've read from the image.  */
@@ -619,7 +624,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 			 p64[i].p_align);
     }
 
-  finish_portion (&ph_buffer, &ph_buffer_size);
+  finish_portion (dwfl, memory_callback, memory_callback_arg, &ph_buffer, &ph_buffer_size);
 
   /* We must have seen the segment covering offset 0, or else the ELF
      header we read at START was not produced by these program headers.  */
@@ -811,7 +816,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 	}
       free (dyns);
     }
-  finish_portion (&dyn_data, &dyn_data_size);
+  finish_portion (dwfl, memory_callback, memory_callback_arg, &dyn_data, &dyn_data_size);
 
   /* We'll use the name passed in or a stupid default if not DT_SONAME.  */
   if (name == NULL)
@@ -872,7 +877,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
   /* At this point we do not need BUILD_ID or NAME any more.
      They have been copied.  */
   free (build_id);
-  finish_portion (&soname, &soname_size);
+  finish_portion (dwfl, memory_callback, memory_callback_arg, &soname, &soname_size);
 
   if (unlikely (mod == NULL))
     {
-- 
2.26.2



More information about the Elfutils-devel mailing list