From patchwork Fri Apr 15 09:25:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yanchao X-Patchwork-Id: 52977 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56383385B804 for ; Fri, 15 Apr 2022 09:25:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56383385B804 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650014732; bh=7DUHBrCR7BXPknN8ZIOja5wehC4sVxMMELqxiEl7BwE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=LpzMACOHP4ANtxrWeGHGe//K/bJ4nsyJut/4aY03j+pZPhBNhfeCivSUGug0R9/13 fDyyOs2Z69UeSh1g2kSlKbfx5y8zXsk+vVa95jFi99+dOUoHtzwaZ3/8O918h8A1Ps OeCIKhONXaSbpX+9qZVSNJ62ai9zkKI/FUyEOb+Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by sourceware.org (Postfix) with ESMTPS id EEA3D3857C4E for ; Fri, 15 Apr 2022 09:25:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EEA3D3857C4E Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KfrTv333VzgYth; Fri, 15 Apr 2022 17:23:15 +0800 (CST) Received: from dggpeml100016.china.huawei.com (7.185.36.216) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 15 Apr 2022 17:25:06 +0800 Received: from huawei.com (10.174.179.133) by dggpeml100016.china.huawei.com (7.185.36.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 15 Apr 2022 17:25:05 +0800 To: Subject: [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG Date: Fri, 15 Apr 2022 17:25:05 +0800 Message-ID: <20220415092505.338-1-yangyanchao6@huawei.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.179.133] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml100016.china.huawei.com (7.185.36.216) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yang Yanchao via Libc-alpha From: Yang Yanchao Reply-To: Yang Yanchao Cc: linfeilong@huawei.com, schwab@linux-m68k.org, fweimer@redhat.com Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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); }