[PATCH 01/12] segment_report_module: Get rid of segment_read()

tbaeder@redhat.com tbaeder@redhat.com
Mon Nov 23 12:27:01 GMT 2020


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

Just inline the memory_callback call everywhere segmenty_read was used.

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

diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index c7725002..c587efd7 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -257,18 +257,11 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 
   GElf_Addr start = dwfl->lookup_addr[segment];
 
-  inline bool segment_read (int segndx,
-			    void **buffer, size_t *buffer_available,
-			    GElf_Addr addr, size_t minread)
-  {
-    return ! (*memory_callback) (dwfl, segndx, buffer, buffer_available,
-				 addr, minread, memory_callback_arg);
-  }
-
   inline void release_buffer (void **buffer, size_t *buffer_available)
   {
     if (*buffer != NULL)
-      (void) segment_read (-1, buffer, buffer_available, 0, 0);
+      (*memory_callback) (dwfl, -1, buffer, buffer_available, 0, 0,
+                          memory_callback_arg);
   }
 
   /* First read in the file header and check its sanity.  */
@@ -282,8 +275,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
      here so we can always safely free it.  */
   void *phdrsp = NULL;
 
-  if (segment_read (ndx, &buffer, &buffer_available,
-		    start, sizeof (Elf64_Ehdr))
+  if (! (*memory_callback) (dwfl, ndx, &buffer, &buffer_available,
+                            start, sizeof (Elf64_Ehdr), memory_callback_arg)
       || memcmp (buffer, ELFMAG, SELFMAG) != 0)
     goto out;
 
@@ -301,8 +294,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
       {
 	*data = NULL;
 	*data_size = filesz;
-	return segment_read (addr_segndx (dwfl, segment, vaddr, false),
-			     data, data_size, vaddr, filesz);
+        return ! (*memory_callback) (dwfl, addr_segndx (dwfl, segment, vaddr, false),
+                                     data, data_size, vaddr, filesz, memory_callback_arg);
       }
 
     /* We already have this whole note segment from our initial read.  */
@@ -908,8 +901,9 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
       {
 	void *into = contents + offset;
 	size_t read_size = size;
-	(void) segment_read (addr_segndx (dwfl, segment, vaddr, false),
-			     &into, &read_size, vaddr, size);
+        (*memory_callback) (dwfl, addr_segndx (dwfl, segment, vaddr, false),
+                            &into, &read_size, vaddr, size,
+                            memory_callback_arg);
       }
 
       if (contiguous < file_trimmed_end)
-- 
2.26.2



More information about the Elfutils-devel mailing list