* [PATCH] ar: Pull should_truncate_fname() into file scope
@ 2021-02-03 14:44 tbaeder
2021-02-05 17:49 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: tbaeder @ 2021-02-03 14:44 UTC (permalink / raw)
To: elfutils-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-05 17:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 14:44 [PATCH] ar: Pull should_truncate_fname() into file scope tbaeder
2021-02-05 17:49 ` Mark Wielaard
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).