]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Pull add_dump_section() into file scope
authorTimm Bäder <tbaeder@redhat.com>
Fri, 8 Jan 2021 08:16:29 +0000 (09:16 +0100)
committerMark Wielaard <mark@klomp.org>
Sat, 30 Jan 2021 19:52:06 +0000 (20:52 +0100)
Get rid of a nested function this way.

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

index a7c9d2e80ccab829564ba9c0e6809eeb6bf75963..86dda4bc1e643101e74b9abafd00438c9e7996fb 100644 (file)
@@ -1,3 +1,9 @@
+2021-01-08  Timm Bäder  <tbaeder@redhat.com>
+
+       * readelf.c (parse_opt): Lift add_dump_section function to...
+       (add_dump_section): ...here. New top level function. Added key
+       argument.
+
 2021-01-08  Timm Bäder  <tbaeder@redhat.com>
 
        * arlib-argp.c (help_filter): Lift text_for_default function to...
index 0001a3d877dd694eccfb4fade8f6388b9a887720..6233b26863e9a7b626c8c62dda0a59a7173a7191 100644 (file)
@@ -381,24 +381,26 @@ main (int argc, char *argv[])
   return error_message_count != 0;
 }
 
+static void
+add_dump_section (const char *name,
+                 int key,
+                 bool implicit)
+{
+  struct section_argument *a = xmalloc (sizeof *a);
+  a->arg = name;
+  a->next = NULL;
+  a->implicit = implicit;
+  struct section_argument ***tailp
+    = key == 'x' ? &dump_data_sections_tail : &string_sections_tail;
+  **tailp = a;
+  *tailp = &a->next;
+}
 
 /* Handle program arguments.  */
 static error_t
 parse_opt (int key, char *arg,
           struct argp_state *state __attribute__ ((unused)))
 {
-  void add_dump_section (const char *name, bool implicit)
-  {
-    struct section_argument *a = xmalloc (sizeof *a);
-    a->arg = name;
-    a->next = NULL;
-    a->implicit = implicit;
-    struct section_argument ***tailp
-      = key == 'x' ? &dump_data_sections_tail : &string_sections_tail;
-    **tailp = a;
-    *tailp = &a->next;
-  }
-
   switch (key)
     {
     case 'a':
@@ -414,9 +416,9 @@ parse_opt (int key, char *arg,
       print_arch = true;
       print_notes = true;
       implicit_debug_sections |= section_exception;
-      add_dump_section (".strtab", true);
-      add_dump_section (".dynstr", true);
-      add_dump_section (".comment", true);
+      add_dump_section (".strtab", key, true);
+      add_dump_section (".dynstr", key, true);
+      add_dump_section (".comment", key, true);
       any_control_option = true;
       break;
     case 'A':
@@ -562,7 +564,7 @@ parse_opt (int key, char *arg,
        }
       FALLTHROUGH;
     case 'x':
-      add_dump_section (arg, false);
+      add_dump_section (arg, key, false);
       any_control_option = true;
       break;
     case 'N':