public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] elfcompress: Pull set_section() into file scope
@ 2021-02-17  8:45 tbaeder
  2021-02-17  8:45 ` [PATCH 2/4] elfcompress: Pull get_section() " tbaeder
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: tbaeder @ 2021-02-17  8:45 UTC (permalink / raw)
  To: elfutils-devel

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

diff --git a/src/elfcompress.c b/src/elfcompress.c
index 1b5b1e36..65a922a7 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -52,6 +52,8 @@ static const char *foutput = NULL;
 #define T_DECOMPRESS 1    /* none */
 #define T_COMPRESS_ZLIB 2 /* zlib */
 #define T_COMPRESS_GNU  3 /* zlib-gnu */
+#define WORD_BITS (8U * sizeof (unsigned int))
+
 static int type = T_UNSET;
 
 struct section_pattern
@@ -242,6 +244,12 @@ compress_section (Elf_Scn *scn, size_t orig_size, const char *name,
   return res;
 }
 
+static void
+set_section (unsigned int *sections, size_t ndx)
+{
+  sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS));
+}
+
 static int
 process_file (const char *fname)
 {
@@ -275,12 +283,6 @@ process_file (const char *fname)
   /* How many sections are we talking about?  */
   size_t shnum = 0;
 
-#define WORD_BITS (8U * sizeof (unsigned int))
-  void set_section (size_t ndx)
-  {
-    sections[ndx / WORD_BITS] |= (1U << (ndx % WORD_BITS));
-  }
-
   bool get_section (size_t ndx)
   {
     return (sections[ndx / WORD_BITS] & (1U << (ndx % WORD_BITS))) != 0;
@@ -498,7 +500,7 @@ process_file (const char *fname)
 	  else if (shdr->sh_type != SHT_NOBITS
 	      && (shdr->sh_flags & SHF_ALLOC) == 0)
 	    {
-	      set_section (ndx);
+	      set_section (sections, ndx);
 	      /* Check if we might want to change this section name.  */
 	      if (! adjust_names
 		  && ((type != T_COMPRESS_GNU
-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-01 22:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17  8:45 [PATCH 1/4] elfcompress: Pull set_section() into file scope tbaeder
2021-02-17  8:45 ` [PATCH 2/4] elfcompress: Pull get_section() " tbaeder
2021-03-01 22:03   ` Mark Wielaard
2021-02-17  8:45 ` [PATCH 3/4] elfcompress: Pull get_sections() " tbaeder
2021-03-01 22:04   ` Mark Wielaard
2021-02-17  8:45 ` [PATCH 4/4] elfcompress: Replace cleanup() with label tbaeder
2021-03-01 22:10   ` Mark Wielaard
2021-03-01 22:03 ` [PATCH 1/4] elfcompress: Pull set_section() into file scope Mark Wielaard

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).