public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Yang Yanchao <yangyanchao6@huawei.com>
To: <libc-alpha@sourceware.org>, Carlos O'Donell <carlos@redhat.com>
Cc: <linfeilong@huawei.com>, <fweimer@redhat.com>,
	<schwab@linux-m68k.org>, <liqingqing3@huawei.com>
Subject: RE: [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG
Date: Tue, 28 Jun 2022 16:10:21 +0800	[thread overview]
Message-ID: <fd8a7635-b7de-da82-db06-e45825388dab@huawei.com> (raw)
In-Reply-To: <32fcdf7272e74ec894876227b00c8e3d@huawei.com>


On 2022/4/15 15:36, Yang Yanchao wrote:
> Use -Werror and -DNDEBUG at the same time will causes the following 
> compilation errors:
> 
> 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 will disables the assertion.
> Therefore, only the variables used by assertions do not take effect.
> use __attribute__ ((unused)) to disable this warning.
> ---
>  elf/cache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/elf/cache.c b/elf/cache.c index dbf4c83a7a..e92860023c
> 100644
> --- a/elf/cache.c
> +++ b/elf/cache.c
> @@ -754,7 +754,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);
>      }
> 

ping again

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <32fcdf7272e74ec894876227b00c8e3d@huawei.com>
2022-06-28  8:10 ` Yang Yanchao [this message]
2022-06-28  8:31   ` Florian Weimer
2022-04-15  9:25 Yang Yanchao

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=fd8a7635-b7de-da82-db06-e45825388dab@huawei.com \
    --to=yangyanchao6@huawei.com \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linfeilong@huawei.com \
    --cc=liqingqing3@huawei.com \
    --cc=schwab@linux-m68k.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).