From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 743233834698; Tue, 28 Jun 2022 08:31:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 743233834698 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] elf: Fix compile error with -Werror and -DNDEBUG X-Act-Checkin: glibc X-Git-Author: Yang Yanchao X-Git-Refname: refs/heads/master X-Git-Oldrev: cfdc4df66ce1464611e1b508f7a5a8f38afd5337 X-Git-Newrev: 5e89ed42fd8997414732525c9460878d65363b3f Message-Id: <20220628083122.743233834698@sourceware.org> Date: Tue, 28 Jun 2022 08:31:22 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2022 08:31:22 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5e89ed42fd8997414732525c9460878d65363b3f commit 5e89ed42fd8997414732525c9460878d65363b3f Author: Yang Yanchao 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); }