[PATCH 07/12] segment_report_module: Get rid of nested final_read() function

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


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

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

diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 6c6f9f37..a69ead8f 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -934,15 +934,6 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
       if (unlikely (contents == NULL))
 	goto out;
 
-      inline void final_read (size_t offset, GElf_Addr vaddr, size_t size)
-      {
-	void *into = contents + offset;
-	size_t read_size = size;
-        (*memory_callback) (dwfl, addr_segndx (dwfl, segment, vaddr, false),
-                            &into, &read_size, vaddr, size,
-                            memory_callback_arg);
-      }
-
       if (contiguous < file_trimmed_end)
 	{
 	  /* We can't use the memory image verbatim as the file image.
@@ -952,7 +943,13 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 				 GElf_Off offset, GElf_Xword filesz)
 	  {
 	    if (type == PT_LOAD)
-	      final_read (offset, vaddr + bias, filesz);
+              {
+                void *into = contents + offset;
+                size_t read_size = filesz;
+                (*memory_callback) (dwfl, addr_segndx (dwfl, segment, vaddr + bias, false),
+                                    &into, &read_size, vaddr + bias, read_size,
+                                    memory_callback_arg);
+              }
 	  }
 
 	  if (ei_class == ELFCLASS32)
@@ -973,7 +970,13 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
 	  memcpy (contents, buffer, have);
 
 	  if (have < file_trimmed_end)
-	    final_read (have, start + have, file_trimmed_end - have);
+            {
+              void *into = contents + have;
+              size_t read_size = file_trimmed_end - have;
+                (*memory_callback) (dwfl, addr_segndx (dwfl, segment, start + have, false),
+                                    &into, &read_size, start + have, read_size,
+                                    memory_callback_arg);
+            }
 	}
 
       elf = elf_memory (contents, file_trimmed_end);
-- 
2.26.2



More information about the Elfutils-devel mailing list