elfcompress: Pull get_section() into file scope
authorTimm Bäder <tbaeder@redhat.com>
Wed, 17 Feb 2021 08:45:08 +0000 (09:45 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 1 Mar 2021 22:01:13 +0000 (23:01 +0100)
Get rid of a nested function this way.

Signed-off-by: Timm Bäder <tbaeder@redhat.com>
src/ChangeLog
src/elfcompress.c

index 0740807..d810cf9 100644 (file)
@@ -1,5 +1,11 @@
 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.
+
+2021-02-17  Timm Bäder  <tbaeder@redhat.com>
+
        * elfcompress.c (process_file): Move set_section function...
        (set_section): ...to top-level static function taking a
        section array.
index 65a922a..2dc74a0 100644 (file)
@@ -250,6 +250,12 @@ set_section (unsigned int *sections, size_t ndx)
   sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS));
 }
 
+static bool
+get_section (unsigned int *sections, size_t ndx)
+{
+  return (sections[ndx / WORD_BITS] & (1U << (ndx % WORD_BITS))) != 0;
+}
+
 static int
 process_file (const char *fname)
 {
@@ -283,11 +289,6 @@ process_file (const char *fname)
   /* How many sections are we talking about?  */
   size_t shnum = 0;
 
-  bool get_section (size_t ndx)
-  {
-    return (sections[ndx / WORD_BITS] & (1U << (ndx % WORD_BITS))) != 0;
-  }
-
   /* How many sections are we going to change?  */
   size_t get_sections (void)
   {
@@ -689,7 +690,7 @@ process_file (const char *fname)
       /* (de)compress if section matched.  */
       char *sname = NULL;
       char *newname = NULL;
-      if (get_section (ndx))
+      if (get_section (sections, ndx))
        {
          GElf_Shdr shdr_mem;
          GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);