public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] elf: Fix compile error with -Werror and -DNDEBUG
Date: Tue, 28 Jun 2022 08:31:22 +0000 (GMT)	[thread overview]
Message-ID: <20220628083122.743233834698@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5e89ed42fd8997414732525c9460878d65363b3f

commit 5e89ed42fd8997414732525c9460878d65363b3f
Author: Yang Yanchao <yangyanchao6@huawei.com>
Date:   Fri Apr 15 17:25:05 2022 +0800

    elf: Fix compile error with -Werror and -DNDEBUG
    
    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.

Diff:
---
 elf/cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/elf/cache.c b/elf/cache.c
index abe2e49a66..3d7d3a67bf 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -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);
     }


                 reply	other threads:[~2022-06-28  8:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220628083122.743233834698@sourceware.org \
    --to=fw@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).