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 7882E3857C60 for ; Wed, 17 Feb 2021 08:45:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7882E3857C60 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-475-MFglvYptMh6hYbEdL7k7Rw-1; Wed, 17 Feb 2021 03:45:12 -0500 X-MC-Unique: MFglvYptMh6hYbEdL7k7Rw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A89086EE20 for ; Wed, 17 Feb 2021 08:45:11 +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 2542160C61 for ; Wed, 17 Feb 2021 08:45:10 +0000 (UTC) From: tbaeder@redhat.com To: elfutils-devel@sourceware.org Subject: [PATCH 1/4] elfcompress: Pull set_section() into file scope Date: Wed, 17 Feb 2021 09:45:07 +0100 Message-Id: <20210217084510.135286-1-tbaeder@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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:45:15 -0000 From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/elfcompress.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/elfcompress.c b/src/elfcompress.c index 1b5b1e36..65a922a7 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -52,6 +52,8 @@ static const char *foutput = NULL; #define T_DECOMPRESS 1 /* none */ #define T_COMPRESS_ZLIB 2 /* zlib */ #define T_COMPRESS_GNU 3 /* zlib-gnu */ +#define WORD_BITS (8U * sizeof (unsigned int)) + static int type = T_UNSET; struct section_pattern @@ -242,6 +244,12 @@ compress_section (Elf_Scn *scn, size_t orig_size, const char *name, return res; } +static void +set_section (unsigned int *sections, size_t ndx) +{ + sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS)); +} + static int process_file (const char *fname) { @@ -275,12 +283,6 @@ process_file (const char *fname) /* How many sections are we talking about? */ size_t shnum = 0; -#define WORD_BITS (8U * sizeof (unsigned int)) - void set_section (size_t ndx) - { - sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS)); - } - bool get_section (size_t ndx) { return (sections[ndx / WORD_BITS] & (1U << (ndx % WORD_BITS))) != 0; @@ -498,7 +500,7 @@ process_file (const char *fname) else if (shdr->sh_type != SHT_NOBITS && (shdr->sh_flags & SHF_ALLOC) == 0) { - set_section (ndx); + set_section (sections, ndx); /* Check if we might want to change this section name. */ if (! adjust_names && ((type != T_COMPRESS_GNU -- 2.26.2