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 E90803844072 for ; Mon, 23 Nov 2020 12:27:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E90803844072 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-316-gb9oWyKlNQ2NfJmWoZxaDQ-1; Mon, 23 Nov 2020 07:27:26 -0500 X-MC-Unique: gb9oWyKlNQ2NfJmWoZxaDQ-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 2A5C58030DA for ; Mon, 23 Nov 2020 12:27:25 +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 992971E2C8 for ; Mon, 23 Nov 2020 12:27:24 +0000 (UTC) From: tbaeder@redhat.com To: elfutils-devel@sourceware.org Subject: [PATCH 01/12] segment_report_module: Get rid of segment_read() Date: Mon, 23 Nov 2020 13:27:01 +0100 Message-Id: <20201123122712.3799676-2-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_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: Mon, 23 Nov 2020 12:27:29 -0000 From: Timm Bäder Just inline the memory_callback call everywhere segmenty_read was used. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index c7725002..c587efd7 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -257,18 +257,11 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, GElf_Addr start = dwfl->lookup_addr[segment]; - inline bool segment_read (int segndx, - void **buffer, size_t *buffer_available, - GElf_Addr addr, size_t minread) - { - return ! (*memory_callback) (dwfl, segndx, buffer, buffer_available, - addr, minread, memory_callback_arg); - } - inline void release_buffer (void **buffer, size_t *buffer_available) { if (*buffer != NULL) - (void) segment_read (-1, buffer, buffer_available, 0, 0); + (*memory_callback) (dwfl, -1, buffer, buffer_available, 0, 0, + memory_callback_arg); } /* First read in the file header and check its sanity. */ @@ -282,8 +275,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, here so we can always safely free it. */ void *phdrsp = NULL; - if (segment_read (ndx, &buffer, &buffer_available, - start, sizeof (Elf64_Ehdr)) + if (! (*memory_callback) (dwfl, ndx, &buffer, &buffer_available, + start, sizeof (Elf64_Ehdr), memory_callback_arg) || memcmp (buffer, ELFMAG, SELFMAG) != 0) goto out; @@ -301,8 +294,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, { *data = NULL; *data_size = filesz; - return segment_read (addr_segndx (dwfl, segment, vaddr, false), - data, data_size, vaddr, filesz); + return ! (*memory_callback) (dwfl, addr_segndx (dwfl, segment, vaddr, false), + data, data_size, vaddr, filesz, memory_callback_arg); } /* We already have this whole note segment from our initial read. */ @@ -908,8 +901,9 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, { void *into = contents + offset; size_t read_size = size; - (void) segment_read (addr_segndx (dwfl, segment, vaddr, false), - &into, &read_size, vaddr, size); + (*memory_callback) (dwfl, addr_segndx (dwfl, segment, vaddr, false), + &into, &read_size, vaddr, size, + memory_callback_arg); } if (contiguous < file_trimmed_end) -- 2.26.2