From 71b7401496f760a4f748e8d288331b64e2263d00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 17 Feb 2021 09:45:08 +0100 Subject: [PATCH] elfcompress: Pull get_section() into file scope MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/ChangeLog | 6 ++++++ src/elfcompress.c | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0740807c3..d810cf934 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2021-02-17 Timm Bäder + + * 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 * elfcompress.c (process_file): Move set_section function... diff --git a/src/elfcompress.c b/src/elfcompress.c index 65a922a72..2dc74a0c1 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -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); -- 2.47.2