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 924013857C60 for ; Wed, 17 Feb 2021 08:43:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 924013857C60 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-225--GP65NzuOlOpFaaxjABh3Q-1; Wed, 17 Feb 2021 03:43:52 -0500 X-MC-Unique: -GP65NzuOlOpFaaxjABh3Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD70A80197C for ; Wed, 17 Feb 2021 08:43:51 +0000 (UTC) Received: from hostfoo.redhat.com (ovpn-112-165.ams2.redhat.com [10.36.112.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DDD31B4B4 for ; Wed, 17 Feb 2021 08:43:51 +0000 (UTC) From: tbaeder@redhat.com To: elfutils-devel@sourceware.org Subject: [PATCH 3/5] unstrip: Inline find_unalloc_section() into only caller Date: Wed, 17 Feb 2021 09:43:46 +0100 Message-Id: <20210217084348.135014-3-tbaeder@redhat.com> In-Reply-To: <20210217084348.135014-1-tbaeder@redhat.com> References: <20210217084348.135014-1-tbaeder@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.7 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_LOW, 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: Wed, 17 Feb 2021 08:43:55 -0000 From: Timm Bäder Get rid of an unnecessary nested function this way. Signed-off-by: Timm Bäder --- src/unstrip.c | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/unstrip.c b/src/unstrip.c index 72fabac8..90e02831 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -1452,29 +1452,6 @@ more sections in stripped file than debug file -- arguments reversed?")); stripped_symtab = §ions[nalloc]; } - /* Locate a matching unallocated section in SECTIONS. */ - inline struct section *find_unalloc_section (const GElf_Shdr *shdr, - const char *name, - const char *sig) - { - size_t l = nalloc, u = stripped_shnum - 1; - while (l < u) - { - size_t i = (l + u) / 2; - struct section *sec = §ions[i]; - int cmp = compare_unalloc_sections (shdr, &sec->shdr, - name, sec->name, - sig, sec->sig); - if (cmp < 0) - u = i; - else if (cmp > 0) - l = i + 1; - else - return sec; - } - return NULL; - } - Elf_Data *shstrtab = elf_getdata (elf_getscn (unstripped, unstripped_shstrndx), NULL); ELF_CHECK (shstrtab != NULL, @@ -1536,9 +1513,27 @@ more sections in stripped file than debug file -- arguments reversed?")); } else { - /* Look for the section that matches. */ - sec = find_unalloc_section (shdr, name, - get_group_sig (unstripped, shdr)); + /* Locate a matching unallocated section in SECTIONS. */ + const char *sig = get_group_sig (unstripped, shdr); + size_t l = nalloc, u = stripped_shnum - 1; + while (l < u) + { + size_t i = (l + u) / 2; + struct section *section = §ions[i]; + int cmp = compare_unalloc_sections (shdr, §ion->shdr, + name, section->name, + sig, section->sig); + if (cmp < 0) + u = i; + else if (cmp > 0) + l = i + 1; + else + { + sec = section; + break; + } + } + if (sec == NULL) { /* An additional unallocated section is fine if not SHT_NOBITS. -- 2.26.2