From: tbaeder@redhat.com
To: elfutils-devel@sourceware.org
Subject: [PATCH 03/12] segment_report_module: Pull finish_portion() info file scope
Date: Mon, 23 Nov 2020 13:27:03 +0100 [thread overview]
Message-ID: <20201123122712.3799676-4-tbaeder@redhat.com> (raw)
In-Reply-To: <20201123122712.3799676-1-tbaeder@redhat.com>
From: Timm Bäder <tbaeder@redhat.com>
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
---
libdwfl/dwfl_segment_report_module.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 848c3bec..c55168ed 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -232,6 +232,16 @@ invalid_elf (Elf *elf, bool disk_file_has_build_id,
return false;
}
+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)
+ (*memory_callback) (dwfl, -1, data, data_size, 0, 0, memory_callback_arg);
+}
+
int
dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
Dwfl_Memory_Callback *memory_callback,
@@ -297,12 +307,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)
- (*memory_callback) (dwfl, -1, data, data_size, 0, 0, memory_callback_arg);
- }
-
/* Extract the information we need from the file header. */
const unsigned char *e_ident;
unsigned char ei_class;
@@ -509,7 +513,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. */
@@ -606,7 +610,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. */
@@ -798,7 +802,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)
@@ -859,7 +863,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
next prev parent reply other threads:[~2020-11-23 12:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-23 12:27 Remove nested functions from libdwfl V2 tbaeder
2020-11-23 12:27 ` [PATCH 01/12] segment_report_module: Get rid of segment_read() tbaeder
2020-11-23 12:27 ` [PATCH 02/12] segment_report_module: Remove nested release_buffer() function tbaeder
2020-11-23 12:27 ` tbaeder [this message]
2020-11-23 12:27 ` [PATCH 04/12] segment_report_module: Pull read_portion() into file scope tbaeder
2020-11-23 12:27 ` [PATCH 05/12] segment_report_module: Use a struct for build id information tbaeder
2020-11-23 12:27 ` [PATCH 06/12] segment_report_module: Pull consider_notes() into file scope tbaeder
2020-11-23 12:27 ` [PATCH 07/12] segment_report_module: Get rid of nested final_read() function tbaeder
2020-11-23 12:27 ` [PATCH 08/12] segment_report_module: Use one loop for p32/p64 arrays tbaeder
2020-11-23 12:27 ` [PATCH 09/12] segment_report_module: Inline read_phdr() into only caller tbaeder
2020-11-23 12:27 ` [PATCH 10/12] segment_report_module: Unify d32/d64 loops tbaeder
2020-11-23 12:27 ` [PATCH 11/12] segment_report_module: Inline consider_dyn() into only caller tbaeder
2020-11-23 12:27 ` [PATCH 12/12] segment_report_module: Inline consider_phdr() " tbaeder
2020-11-25 16:33 ` Remove nested functions from libdwfl V2 Mark Wielaard
2020-11-26 11:31 ` Timm Bäder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201123122712.3799676-4-tbaeder@redhat.com \
--to=tbaeder@redhat.com \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).