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 536C43A4B81D for ; Thu, 12 Nov 2020 15:04:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 536C43A4B81D 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-531-yB9p2Jo5OyimK0Iel8MHRw-1; Thu, 12 Nov 2020 10:04:42 -0500 X-MC-Unique: yB9p2Jo5OyimK0Iel8MHRw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D55A18B9EC3 for ; Thu, 12 Nov 2020 15:04:41 +0000 (UTC) Received: from hostfoo.redhat.com (ovpn-113-115.ams2.redhat.com [10.36.113.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F91555766; Thu, 12 Nov 2020 15:04:40 +0000 (UTC) From: =?UTF-8?q?Timm=20B=C3=A4der?= To: elfutils-devel@sourceware.org Subject: [PATCH 05/14] segment_report_module: Pull finish_portion() info file scope Date: Thu, 12 Nov 2020 16:04:03 +0100 Message-Id: <20201112150412.2137981-6-tbaeder@redhat.com> In-Reply-To: <20201112150412.2137981-1-tbaeder@redhat.com> References: <20201112150412.2137981-1-tbaeder@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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_H4, 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: Thu, 12 Nov 2020 15:04:45 -0000 Signed-off-by: Timm Bäder --- 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