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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 39AA83A4B82F for ; Thu, 12 Nov 2020 15:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 39AA83A4B82F 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-580-3YSwjpWMOJOjpYpOW_C-Zw-1; Thu, 12 Nov 2020 10:04:47 -0500 X-MC-Unique: 3YSwjpWMOJOjpYpOW_C-Zw-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 6FE4C8049D7 for ; Thu, 12 Nov 2020 15:04:46 +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 95C9355766; Thu, 12 Nov 2020 15:04:45 +0000 (UTC) From: =?UTF-8?q?Timm=20B=C3=A4der?= To: elfutils-devel@sourceware.org Subject: [PATCH 09/14] segment_report_module: Get rid of nested final_read() function Date: Thu, 12 Nov 2020 16:04:07 +0100 Message-Id: <20201112150412.2137981-10-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.4 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_H5, 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:50 -0000 Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 76686a72..80f97cfd 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -948,15 +948,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; - (void) segment_read (dwfl, memory_callback, memory_callback_arg, - addr_segndx (dwfl, segment, vaddr, false), - &into, &read_size, vaddr, size); - } - if (contiguous < file_trimmed_end) { /* We can't use the memory image verbatim as the file image. @@ -966,7 +957,14 @@ 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; + (void)segment_read (dwfl, memory_callback, memory_callback_arg, + addr_segndx (dwfl, segment, vaddr + bias, false), + &into, &read_size, vaddr + bias, read_size); + + } } if (ei_class == ELFCLASS32) @@ -987,7 +985,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; + (void)segment_read (dwfl, memory_callback, memory_callback_arg, + addr_segndx (dwfl, segment, start + have, false), + &into, &read_size, start + have, read_size); + } } elf = elf_memory (contents, file_trimmed_end); -- 2.26.2