summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2021-02-17 09:45:09 +0100
committerMark Wielaard <mark@klomp.org>2021-03-01 23:01:29 +0100
commit0df0e8e05a1c06ff164b87d5571b793ae7ad91ef (patch)
tree6990c82c210701c849c8a1e52299027eb2083094
parent71b7401496f760a4f748e8d288331b64e2263d00 (diff)
downloadelfutils-0df0e8e05a1c06ff164b87d5571b793ae7ad91ef.tar.gz
elfcompress: Pull get_sections() into file scope
Get rid of a nested function this way. Signed-off-by: Timm Bäder <tbaeder@redhat.com>
-rw-r--r--src/ChangeLog6
-rw-r--r--src/elfcompress.c21
2 files changed, 17 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d810cf93..29f04e71 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2021-02-17 Timm Bäder <tbaeder@redhat.com>
+ * elfcompress.c (process_file): Move get_sections function...
+ (get_section): ...to top-level static function taking an
+ sections array and shnum.
+
+2021-02-17 Timm Bäder <tbaeder@redhat.com>
+
* elfcompress.c (process_file): Move get_section function...
(get_section): ...to top-level static function taking an
sections array.
diff --git a/src/elfcompress.c b/src/elfcompress.c
index 2dc74a0c..65e28f0e 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -256,6 +256,16 @@ get_section (unsigned int *sections, size_t ndx)
return (sections[ndx / WORD_BITS] & (1U << (ndx % WORD_BITS))) != 0;
}
+/* How many sections are we going to change? */
+static size_t
+get_sections (unsigned int *sections, size_t shnum)
+{
+ size_t s = 0;
+ for (size_t i = 0; i < shnum / WORD_BITS + 1; i++)
+ s += __builtin_popcount (sections[i]);
+ return s;
+}
+
static int
process_file (const char *fname)
{
@@ -289,15 +299,6 @@ process_file (const char *fname)
/* How many sections are we talking about? */
size_t shnum = 0;
- /* How many sections are we going to change? */
- size_t get_sections (void)
- {
- size_t s = 0;
- for (size_t i = 0; i < shnum / WORD_BITS + 1; i++)
- s += __builtin_popcount (sections[i]);
- return s;
- }
-
int cleanup (int res)
{
elf_end (elf);
@@ -552,7 +553,7 @@ process_file (const char *fname)
}
}
- if (foutput == NULL && get_sections () == 0)
+ if (foutput == NULL && get_sections (sections, shnum) == 0)
{
if (verbose > 0)
printf ("Nothing to do.\n");