From patchwork Sat Apr 2 03:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yanchao X-Patchwork-Id: 52594 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 DBF123857C48 for ; Sat, 2 Apr 2022 03:23:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBF123857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1648869809; bh=/wwUHDeeZBVg9ByddNk3X/Wf7HAUSe5PTuXg8dVU148=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=XvxcUH54Pi1BMqgjGoJa/AUdcNGMTolX6FvX/+1Qe2OHTY1pDPe6Nw8vCs/vdyhzr 9bvjUlFYsE+cjUpFnozxZjhtP41oLZ9arAyfnJ/vLpuWUwF2OALdLB9F18jifkUKRT xrjjkbwZy79JxAxuq3Ai8abcRLMrjRRMwU1ZUCXY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by sourceware.org (Postfix) with ESMTPS id 83DE03858C53 for ; Sat, 2 Apr 2022 03:23:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83DE03858C53 Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KVj1b1BRqzBrtb; Sat, 2 Apr 2022 11:18:59 +0800 (CST) Received: from dggpeml100016.china.huawei.com (7.185.36.216) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 2 Apr 2022 11:23:05 +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.2308.21; Sat, 2 Apr 2022 11:23:05 +0800 To: Subject: [PATCH] elf: fixes compile error when both enable -Werror and -DNDEBUG Date: Sat, 2 Apr 2022 11:23:04 +0800 Message-ID: <20220402032304.2959-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: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml100016.china.huawei.com (7.185.36.216) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-11.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, 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. Integrate variable assignment and assertion to make compilation pass. Signed-off-by: Yang Yanchao --- elf/cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elf/cache.c b/elf/cache.c index dbf4c83a7a..68cd4d0828 100644 --- a/elf/cache.c +++ b/elf/cache.c @@ -754,8 +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); - assert ((unsigned long long int) (extension_offset - old_offset) < 4); + assert ((unsigned long long int) (extension_offset - + lseek64 (fd, extension_offset, SEEK_SET)) < 4); write_extensions (fd, str_offset, extension_offset); }