From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by sourceware.org (Postfix) with ESMTPS id D6095385AE5C for ; Tue, 28 Jun 2022 08:10:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6095385AE5C Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXHHq05VdzTgGd; Tue, 28 Jun 2022 16:07:03 +0800 (CST) Received: from dggpeml100016.china.huawei.com (7.185.36.216) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 16:10:32 +0800 Received: from [10.174.179.133] (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; Tue, 28 Jun 2022 16:10:31 +0800 Subject: RE: [PATCH v5] elf: fixes compile error when both enable -Werror and -DNDEBUG References: <32fcdf7272e74ec894876227b00c8e3d@huawei.com> To: , Carlos O'Donell CC: , , , From: Yang Yanchao X-Forwarded-Message-Id: <32fcdf7272e74ec894876227b00c8e3d@huawei.com> Message-ID: Date: Tue, 28 Jun 2022 16:10:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <32fcdf7272e74ec894876227b00c8e3d@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.133] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml100016.china.huawei.com (7.185.36.216) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 28 Jun 2022 08:10:37 -0000 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