From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: Yang Yanchao To: CC: , , , 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-List-Received-Date: Fri, 15 Apr 2022 09:25:12 -0000 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