]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
link_map.c: Declare name_no_sysroot only if openat2 RESOLVE_IN_ROOT is supported
authorAaron Merey <amerey@redhat.com>
Tue, 28 Oct 2025 01:49:31 +0000 (21:49 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 28 Oct 2025 02:40:26 +0000 (22:40 -0400)
Rename variable n to name_no_sysroot.  Declare name_no_sysroot only if
openat2 RESOLVE_IN_ROOT is supported to avoid an unused variable warning.

https://sourceware.org/bugzilla/show_bug.cgi?id=33581

Signed-off-by: Aaron Merey <amerey@redhat.com>
libdwfl/link_map.c

index 013a415d1d8cd056f0ad4757d7c8b49e9420a979..5f9341318bde93744d3e42ad88e9843a9077bf0e 100644 (file)
@@ -431,12 +431,14 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
 
          if (sysroot && !name_in_sysroot)
            {
-             const char *n = NULL;
-
              if (asprintf (&sysroot_name, "%s%s", sysroot, name) < 0)
                return release_buffer (&memory_closure, &buffer, &buffer_available, -1);
 
-             n = name;
+#ifdef HAVE_OPENAT2_RESOLVE_IN_ROOT
+             /* The original name does not contain the sysroot as a prefix.
+                Save this for use with openat2.  */
+             const char *name_no_sysroot = name;
+#endif
              name = sysroot_name;
 
 #ifdef HAVE_OPENAT2_RESOLVE_IN_ROOT
@@ -451,7 +453,8 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
              if (sysrootfd < 0)
                return -1;
 
-             fd = syscall (SYS_openat2, sysrootfd, n, &how, sizeof(how));
+             fd = syscall (SYS_openat2, sysrootfd, name_no_sysroot,
+                           &how, sizeof(how));
              err = fd < 0 ? -errno : 0;
 
              close (sysrootfd);