public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: tbaeder@redhat.com
To: elfutils-devel@sourceware.org
Subject: [PATCH 1/5] readelf: Pull add_dump_section() into file scope
Date: Fri,  8 Jan 2021 09:16:29 +0100	[thread overview]
Message-ID: <20210108081633.2202592-2-tbaeder@redhat.com> (raw)
In-Reply-To: <20210108081633.2202592-1-tbaeder@redhat.com>

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/readelf.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/readelf.c b/src/readelf.c
index 829a418d..a95fc0aa 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -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':
-- 
2.26.2


  reply	other threads:[~2021-01-08  8:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  8:16 Remove nested functions from readelf.c tbaeder
2021-01-08  8:16 ` tbaeder [this message]
2021-01-30 19:55   ` [PATCH 1/5] readelf: Pull add_dump_section() into file scope Mark Wielaard
2021-01-08  8:16 ` [PATCH 2/5] readelf: Pull same_set() info " tbaeder
2021-01-30 20:14   ` Mark Wielaard
2021-01-08  8:16 ` [PATCH 3/5] readelf: Pull left() " tbaeder
2021-01-30 20:29   ` Mark Wielaard
2021-01-08  8:16 ` [PATCH 4/5] readelf: Pull regname() into " tbaeder
2021-01-30 20:47   ` Mark Wielaard
2021-01-08  8:16 ` [PATCH 5/5] readelf: Pull advance_pc() " tbaeder
2021-02-01 14:21 ` Remove nested functions from readelf.c Mark Wielaard
2021-02-02 10:07   ` Timm Bäder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210108081633.2202592-2-tbaeder@redhat.com \
    --to=tbaeder@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).