From: tbaeder@redhat.com
To: elfutils-devel@sourceware.org
Subject: [PATCH] ar: Pull should_truncate_fname() into file scope
Date: Wed, 3 Feb 2021 15:44:46 +0100 [thread overview]
Message-ID: <20210203144446.789579-1-tbaeder@redhat.com> (raw)
From: Timm Bäder <tbaeder@redhat.com>
Get rid of a nested function this way.
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
---
src/ar.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/ar.c b/src/ar.c
index 2a17d0d3..66b2c4fd 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
next reply other threads:[~2021-02-03 14:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 14:44 tbaeder [this message]
2021-02-05 17:49 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210203144446.789579-1-tbaeder@redhat.com \
--to=tbaeder@redhat.com \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).