* [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG
@ 2022-04-15 9:25 Yang Yanchao
0 siblings, 0 replies; 3+ messages in thread
From: Yang Yanchao @ 2022-04-15 9:25 UTC (permalink / raw)
To: libc-alpha; +Cc: linfeilong, carlos, fweimer, schwab
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);
}
--
2.33.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG
2022-06-28 8:10 ` Yang Yanchao
@ 2022-06-28 8:31 ` Florian Weimer
0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2022-06-28 8:31 UTC (permalink / raw)
To: Yang Yanchao
Cc: libc-alpha, Carlos O'Donell, linfeilong, schwab, liqingqing3
* Yang Yanchao:
> 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
Sorry for the delay. I've reworded the commit message slightly and
pushed your change.
Thanks,
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG
[not found] <32fcdf7272e74ec894876227b00c8e3d@huawei.com>
@ 2022-06-28 8:10 ` Yang Yanchao
2022-06-28 8:31 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Yang Yanchao @ 2022-06-28 8:10 UTC (permalink / raw)
To: libc-alpha, Carlos O'Donell; +Cc: linfeilong, fweimer, schwab, liqingqing3
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-28 8:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 9:25 [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG Yang Yanchao
[not found] <32fcdf7272e74ec894876227b00c8e3d@huawei.com>
2022-06-28 8:10 ` Yang Yanchao
2022-06-28 8:31 ` Florian Weimer
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).