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 93FA4394C046 for ; Fri, 8 Jan 2021 08:13:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 93FA4394C046 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-321-c0sHvn6zME62AYRQuxarYA-1; Fri, 08 Jan 2021 03:13:38 -0500 X-MC-Unique: c0sHvn6zME62AYRQuxarYA-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 B10FD190A7A6 for ; Fri, 8 Jan 2021 08:13:37 +0000 (UTC) Received: from hostfoo.redhat.com (ovpn-112-148.ams2.redhat.com [10.36.112.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D8881840B for ; Fri, 8 Jan 2021 08:13:36 +0000 (UTC) From: tbaeder@redhat.com To: elfutils-devel@sourceware.org Subject: [PATCH 3/4] ar: Pull should_truncate_fname() into file scope Date: Fri, 8 Jan 2021 09:13:27 +0100 Message-Id: <20210108081328.2202283-4-tbaeder@redhat.com> In-Reply-To: <20210108081328.2202283-1-tbaeder@redhat.com> References: <20210108081328.2202283-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.6 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: Fri, 08 Jan 2021 08:13:43 -0000 From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/ar.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ar.c b/src/ar.c index 2a17d0d3..7d0298dd 100644 --- a/src/ar.c +++ b/src/ar.c @@ -436,6 +436,21 @@ copy_content (Elf *elf, int newfd, off_t off, size_t n) return write_retry (newfd, rawfile + off, n) != (ssize_t) n; } +static inline bool +should_truncate_fname (size_t name_max) +{ + if (errno == ENAMETOOLONG && allow_truncate_fname) + { + if (name_max == 0) + { + long int len = pathconf (".", _PC_NAME_MAX); + if (len > 0) + name_max = len; + } + return name_max != 0; + } + return false; +} static int do_oper_extract (int oper, const char *arfname, char **argv, int argc, @@ -445,21 +460,6 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, memset (found, '\0', sizeof (found)); size_t name_max = 0; - inline bool should_truncate_fname (void) - { - if (errno == ENAMETOOLONG && allow_truncate_fname) - { - if (name_max == 0) - { - long int len = pathconf (".", _PC_NAME_MAX); - if (len > 0) - name_max = len; - } - return name_max != 0; - } - return false; - } - off_t index_off = -1; size_t index_size = 0; off_t cur_off = SARMAG; @@ -615,7 +615,7 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, { int printlen = INT_MAX; - if (should_truncate_fname ()) + if (should_truncate_fname (name_max)) { /* Try to truncate the name. First find out by how much. */ @@ -704,7 +704,7 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, { int printlen = INT_MAX; - if (should_truncate_fname ()) + if (should_truncate_fname (name_max)) { /* Try to truncate the name. First find out by how much. */ -- 2.26.2