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

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

index b12ea319e03a1572e2f2c9e17f40b91992023ac8..4f395f1ef1fb9e2916504ff5073f80f916f09bf1 100644 (file)
@@ -1,3 +1,9 @@
+2021-01-08  Timm Bäder  <tbaeder@redhat.com>
+
+       * readelf.c (print_attributes): Lift left function to...
+       (left): ...here. New file scope function taking Elf_Data and char
+       pointers.
+
 2021-01-08  Timm Bäder  <tbaeder@redhat.com>
 
        * readelf.c (handle_core_registers): Lift same_set function to...
index 04ba4123db254debfa6cc716c5a2429b4c39150e..dfc820ed977404a30bbb23dab63bbc6cc5ea1027 100644 (file)
@@ -3571,6 +3571,13 @@ print_liblist (Ebl *ebl)
     }
 }
 
+static inline size_t
+left (Elf_Data *data,
+      const unsigned char *p)
+{
+  return (const unsigned char *) data->d_buf + data->d_size - p;
+}
+
 static void
 print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr)
 {
@@ -3615,13 +3622,8 @@ print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr)
 
       fputs_unlocked (_("  Owner          Size\n"), stdout);
 
-      inline size_t left (void)
-      {
-       return (const unsigned char *) data->d_buf + data->d_size - p;
-      }
-
       /* Loop over the sections.  */
-      while (left () >= 4)
+      while (left (data, p) >= 4)
        {
          /* Section length.  */
          uint32_t len;
@@ -3630,7 +3632,7 @@ print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr)
          if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
            CONVERT (len);
 
-         if (unlikely (len > left ()))
+         if (unlikely (len > left (data, p)))
            break;
 
          /* Section vendor name.  */