From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id CBEE7386EC51 for ; Mon, 23 Nov 2020 12:27:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CBEE7386EC51 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-BmSBTPk-OLq0pqmK8QZvVA-1; Mon, 23 Nov 2020 07:27:29 -0500 X-MC-Unique: BmSBTPk-OLq0pqmK8QZvVA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1D75106B249 for ; Mon, 23 Nov 2020 12:27:27 +0000 (UTC) Received: from hostfoo.redhat.com (ovpn-112-164.ams2.redhat.com [10.36.112.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FEE71E2C8 for ; Mon, 23 Nov 2020 12:27:26 +0000 (UTC) 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 Message-Id: <20201123122712.3799676-4-tbaeder@redhat.com> In-Reply-To: <20201123122712.3799676-1-tbaeder@redhat.com> References: <20201123122712.3799676-1-tbaeder@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Nov 2020 12:27:34 -0000 From: Timm Bäder Signed-off-by: Timm Bäder --- 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