From: Timm Bäder Date: Fri, 8 Jan 2021 08:16:29 +0000 (+0100) Subject: readelf: Pull add_dump_section() into file scope X-Git-Tag: elfutils-0.183~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4812953335bbaac5058525922f676cfeecfe8ef4;p=thirdparty%2Felfutils.git readelf: Pull add_dump_section() into file scope Get rid of a nested function this way. Signed-off-by: Timm Bäder --- diff --git a/src/ChangeLog b/src/ChangeLog index a7c9d2e80..86dda4bc1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2021-01-08 Timm Bäder + + * 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 * arlib-argp.c (help_filter): Lift text_for_default function to... diff --git a/src/readelf.c b/src/readelf.c index 0001a3d87..6233b2686 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':