]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Fix compile error with -Werror and -DNDEBUG
authorYang Yanchao <yangyanchao6@huawei.com>
Fri, 15 Apr 2022 09:25:05 +0000 (17:25 +0800)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 28 Jun 2022 08:28:48 +0000 (10:28 +0200)
Using -Werror and -DNDEBUG at the same time will trigger the
following compiler error:

cache.c: In function 'save_cache':
cache.c:758:15: error: unused variable 'old_offset' [-Werror=unused-variable]
  758 |       off64_t old_offset = lseek64 (fd, extension_offset, SEEK_SET);
      |               ^~~~~~~~~~

-DNDEBUG disables the assertion, making old_offset unused.
Use __attribute__ ((unused)) to disable this warning.

elf/cache.c

index abe2e49a66fb6cd5606852067201c951c72b4774..3d7d3a67bf4e6d2d171f985951f5874cd47f362d 100644 (file)
@@ -727,7 +727,8 @@ save_cache (const char *cache_name)
   if (opt_format != opt_format_old)
     {
       /* Align file position to 4.  */
-      off64_t old_offset = lseek64 (fd, extension_offset, SEEK_SET);
+      __attribute__ ((unused)) off64_t old_offset
+        = lseek64 (fd, extension_offset, SEEK_SET);
       assert ((unsigned long long int) (extension_offset - old_offset) < 4);
       write_extensions (fd, str_offset, extension_offset);
     }