diff options
author | Timm Bäder <tbaeder@redhat.com> | 2021-02-03 15:44:46 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-02-05 18:46:07 +0100 |
commit | ce0944f72826edb2d197dc6ca250adaa0131f363 (patch) | |
tree | c74bca956c66e460abec8c076c3708f5ceb98baf | |
parent | aa121ea7f19e002c5e4738616342cd1d7be1bfd2 (diff) | |
download | elfutils-ce0944f72826edb2d197dc6ca250adaa0131f363.tar.gz |
ar: Pull should_truncate_fname() into file scope
Get rid of a nested function this way.
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/ar.c | 34 |
2 files changed, 24 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9e30df31..e65620fd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2021-02-03 Timm Bäder <tbaeder@redhat.com> + + * ar.c (do_oper_extract): Extract should_truncate_fname function + to... + (should_truncate_fname): ...here. New file scope function taking + size_t pointer to be read and/or set. + 2021-02-02 Timm Bäder <tbaeder@redhat.com> * readelf.c (print_debug_line_section): Remove unnecessary @@ -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. */ |