Message ID | tencent_32CBE47252C5F69571B40751DE6054082D05@qq.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp507136wru; Thu, 10 Nov 2022 19:02:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4paGvbCpnDuEb5Gx9c/O8LIylFxggfwHHuGAGXgkhIWaFHhuWtfgWYAKbv3UTioOSsqB1R X-Received: by 2002:a17:903:3011:b0:186:f256:c097 with SMTP id o17-20020a170903301100b00186f256c097mr702273pla.27.1668135750326; Thu, 10 Nov 2022 19:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668135750; cv=none; d=google.com; s=arc-20160816; b=HBeOKR7zhKD32jWqi8CHsBjMCEtw/JhP9Lrzi52KhJpc0cgSlts94tqdOgllGCb/MM SpRmVT4WoPAA+IeZeCOmrZc6TBXYYNvSnpyqBlOVU35SYT9ffj+q1cV1rGegUuMtupg8 6Z7aseDI7unRdvjRcOu597jovxwbfTK9hRNOyMftOqqLXzOvZUbOD807M4FMro7A4i0L ZwJzgOa8crwDCSDADTiz+JJZArgdPZtf5S+qYXUm10sLfBS4shIzsOhaKMCnXBm3Rnor ne4B57lNu1w49tp+bpOQPjgRXQHAqZ5J4dKYU9sNc9dHX0+G0lXu6iCTFz1TH3piNW5i EXdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:subject:cc:to:from:message-id :dkim-signature; bh=BL3Df7T2fda2YYRMS2L+HCFmYgkJzAzwFsLU2JM9Hkw=; b=crkWGANIOVx54LmhSdauWDA1ui5kN+PhL7/sIkJGxjJupVpueOsFifOYa1HwCKLzDd fbcN5eOmftS6jnzURmn6ABi/l3L2Vhl7LI0uoPJpBWb2NvoOxjrg5CmLkZjxXH6hEdB5 Xip2W0R9noVTPnIuKpEse8vMNEXLmcuJqXgITugenfd3QFL7qKbEDoublj8cGDa+/YyJ VuX+xu+6S2FzFdI5JL5BOxeZC2ZpUcT5L1frHakRqOqrTO7x9/UAQRdeFPNsTI+EmfEj 0Mkp30xfWji1JlCQaKo+5oMz0t4ElENZc6A5d4Y3dLTnjnkD6iEZPXAQKKyB8H1i2At4 29WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=op116er2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a63f741000000b00439ae52c996si1049090pgk.71.2022.11.10.19.02.16; Thu, 10 Nov 2022 19:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=op116er2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232749AbiKKCtE (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 21:49:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232711AbiKKCsk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 21:48:40 -0500 Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E701E42; Thu, 10 Nov 2022 18:43:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1668134590; bh=BL3Df7T2fda2YYRMS2L+HCFmYgkJzAzwFsLU2JM9Hkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=op116er2zCaFNKU2gJBwvP6wi2j3j4m/14zzKInq1OhzkFqgUn7nRYvVuKHEUIHpe 080wVBrV4wf4Y3iWecSpurBxHBJ0iNEUUuSpN5V7coMkwE/lHka7EiHODm3KtCPBdc rBg70rIolxtvtYf5A2YSYlmjVxEBjBupqsOR+x6w= Received: from localhost.localdomain ([111.199.191.46]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id 95619E78; Fri, 11 Nov 2022 10:37:22 +0800 X-QQ-mid: xmsmtpt1668134242to097gvqf Message-ID: <tencent_32CBE47252C5F69571B40751DE6054082D05@qq.com> X-QQ-XMAILINFO: NQR8mRxMnur9pmo2KIyz9dprN6UpTtnMoo5DdTsNsP5dbyXhL/Dto/WxKS/eji yPnSz9aKaiLE8FYJd/UyyLYRg8KD7lbY5XwlDrzbMiMCFnXnziV/ouqi56ahVuJPpKDMYivtPHj7 hEdOKJu8hyeuPO0TJH1Am3Fyzi5WdqU+vL51uVMogq/cnZwMyqhoH5xeTR5a9Y1wwrCMjeyjYnAO Kn3426Ha/lty+eUNfldE4meYk8g7blNbaGMvkA3SMPfUhayvMa0meed1BZUynFsz3g0Q8S0qaKts mG3g3PZcvTbibyrAwYkUq1gwStRxoygKDFn6buaOLXjKHS0Tgp98MEHrUopCY/XDyxhrbHghf/If E0NGyuFmAVJk89c6sJUEofJ6ffZXzjXXmQ0Wp5No8CxPFpwdmDHzOchxPS0Tf1LW4JkyqjwneM23 prUgJTFe5IFekbfM61Mkez1L+e9is4orQr0EDJWQLs1FETG0T7kVCgbIAkRRpKQeEwbZGRAMICd6 cO2PfCcGo+g90Sx+bQyGvLmyRHFN4Trt65w7tC87SBtrogIaPZew20LJXFFaRpk0Laf1sG44Ycw/ xoQ3Qp/dnjOeOakhdrEOUeCtjBOvLdixMSyB02RD4naS8WW/q9mw35sY9oKeU004o4vGfGG7xfDF //txyYHrQalcHVOQF7G60c76Qou3cw6ulBmX6y3Z/ReGmJx97+ILWOzsP4oybqtA6UiNjm9bIIBk fIZsuCq7SU+2a4WMXx6LuO24Zyl17TrAQnvIabW4zGOxjYpdEbT8VrsNVCbmRkncq8wQ0W7eeIET vHUHsOl3YMe5lAiGdM4TbHRL7VG/xUwYD9NcvgLeSd2UlYB6mD/yFI66ZcMskfsDaEevjZnJBv3E W7bcBMkjoCsNezWV17gi7vqMzqoqfK5IzMGePHJdyl4994IMru+xwppnN7Y0awKFbgPUyn2o1tYf N8xrVY5VUhMHNpyNlQgrKiy7KzEkRIXrkckUDftwNGsJ3ZEkXBqLzOpIuE0CQbM+A4mAmBqHJjIM CMBHVEQw== From: Rong Tao <rtoax@foxmail.com> To: sj@kernel.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, rongtao@cestc.cn, rtoax@foxmail.com, shuah@kernel.org, yuanchu@google.com Subject: [PATCH] selftests/damon: Fix unnecessary compilation warnings Date: Fri, 11 Nov 2022 10:37:20 +0800 X-OQ-MSGID: <20221111023720.15408-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221110200939.101886-1-sj@kernel.org> References: <20221110200939.101886-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749116724319628472?= X-GMAIL-MSGID: =?utf-8?q?1749167112395467541?= |
Series |
selftests/damon: Fix unnecessary compilation warnings
|
|
Commit Message
Rong Tao
Nov. 11, 2022, 2:37 a.m. UTC
From: Rong Tao <rongtao@cestc.cn> When testing overflow and overread, there is no need to keep unnecessary compilation warnings, we should simply ignore them. How to reproduce the problem: $ make -C tools/testing/selftests/ ... warning: ‘write’ reading 4294967295 bytes from a region of size 1 [-Wstringop-overread] warning: ‘read’ writing 4294967295 bytes into a region of size 25 overflows the destination [-Wstringop-overflow=] Signed-off-by: Rong Tao <rongtao@cestc.cn> --- tools/testing/selftests/damon/huge_count_read_write.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
Hi Rong, It would be better if you could notice the version of this patch using 'PATCH v2' like subject prefix from next time. On Fri, 11 Nov 2022 10:37:20 +0800 Rong Tao <rtoax@foxmail.com> wrote: > From: Rong Tao <rongtao@cestc.cn> > > When testing overflow and overread, there is no need to keep unnecessary > compilation warnings, we should simply ignore them. > > How to reproduce the problem: > > $ make -C tools/testing/selftests/ > ... > warning: ‘write’ reading 4294967295 bytes from a region of size 1 > [-Wstringop-overread] > warning: ‘read’ writing 4294967295 bytes into a region of size 25 > overflows the destination [-Wstringop-overflow=] Thank you for indenting as I suggested! BTW, I'm ok to violate the line length limit for quoting commands outputs. > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > --- > tools/testing/selftests/damon/huge_count_read_write.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c > index ad7a6b4cf338..8fbe276870e7 100644 > --- a/tools/testing/selftests/damon/huge_count_read_write.c > +++ b/tools/testing/selftests/damon/huge_count_read_write.c > @@ -8,6 +8,11 @@ > #include <unistd.h> > #include <stdio.h> > > +#pragma GCC diagnostic push > +/* Ignore read(2) overflow and write(2) overread compile warnings */ > +#pragma GCC diagnostic ignored "-Wstringop-overread" This still trigger below error on my old gcc. gcc -Wno-stringop-overread -Wno-stringop-overflow huge_count_read_write.c -o /home/sjpark/linux/tools/testing/selftests/damon/huge_count_read_write huge_count_read_write.c:13:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas] 13 | #pragma GCC diagnostic ignored "-Wstringop-overread" | ^~~~~~~~~~~~~~~~~~~~~ cc1: warning: unrecognized command line option ‘-Wno-stringop-overread’ I don't think that's a blocker of this patch, but hope to hear your opinion. Thanks, SJ > +#pragma GCC diagnostic ignored "-Wstringop-overflow" > + > void write_read_with_huge_count(char *file) > { > int filedesc = open(file, O_RDWR); > @@ -27,6 +32,8 @@ void write_read_with_huge_count(char *file) > close(filedesc); > } > > +#pragma GCC diagnostic pop > + > int main(int argc, char *argv[]) > { > if (argc != 2) { > -- > 2.31.1 >
Hi, Park, I just search on GCC source code, found GCC support "-Wstringop-overread" at least gcc-11.1.0, commit d14c547abd48("Add -Wstringop-overread for reading past the end by string functions."). AND found a testsuite gcc/gcc/testsuite/gcc.dg/pragma-diag-10.c 10 #pragma GCC diagnostic push 11 #pragma GCC diagnostic ignored "-Wstringop-overflow" 12 #pragma GCC diagnostic ignored "-Wstringop-overread" 13 if (c != 0) 14 return __builtin_memchr (s, c, (unsigned long)-1); 15 #pragma GCC diagnostic pop it's totally same as this PATCH. I think the motivation for this patch is to eliminate the compilation warning, maybe one day we will compile the kernel with "-Werror -Wall", at which point this compilation warning will turn into a compilation error, and in case we already know it, we should fix this error in advance. For old gcc, we can add this? #pragma GCC diagnostic push +#if __GNUC__ >= 11 && __GNUC_MINOR__ >= 1 /* Ignore read(2) overflow and write(2) overread compile warnings */ #pragma GCC diagnostic ignored "-Wstringop-overread" #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif What do you think? Good day! Rong Tao
Hi Rong, On Sat, 12 Nov 2022 13:01:04 +0800 Rong Tao <rtoax@foxmail.com> wrote: > Hi, Park, I just search on GCC source code, found GCC support > "-Wstringop-overread" at least gcc-11.1.0, commit d14c547abd48("Add > -Wstringop-overread for reading past the end by string functions."). > > AND found a testsuite gcc/gcc/testsuite/gcc.dg/pragma-diag-10.c > > 10 #pragma GCC diagnostic push > 11 #pragma GCC diagnostic ignored "-Wstringop-overflow" > 12 #pragma GCC diagnostic ignored "-Wstringop-overread" > 13 if (c != 0) > 14 return __builtin_memchr (s, c, (unsigned long)-1); > 15 #pragma GCC diagnostic pop > > it's totally same as this PATCH. > > I think the motivation for this patch is to eliminate the compilation > warning, maybe one day we will compile the kernel with "-Werror -Wall", > at which point this compilation warning will turn into a compilation > error, and in case we already know it, we should fix this error in > advance. > > For old gcc, we can add this? > > #pragma GCC diagnostic push > +#if __GNUC__ >= 11 && __GNUC_MINOR__ >= 1 > /* Ignore read(2) overflow and write(2) overread compile warnings */ > #pragma GCC diagnostic ignored "-Wstringop-overread" > #pragma GCC diagnostic ignored "-Wstringop-overflow" > +#endif > > What do you think? I think it looks great! Looking forward to your v3 patch! Thanks, SJ > > Good day! > Rong Tao
diff --git a/tools/testing/selftests/damon/huge_count_read_write.c b/tools/testing/selftests/damon/huge_count_read_write.c index ad7a6b4cf338..8fbe276870e7 100644 --- a/tools/testing/selftests/damon/huge_count_read_write.c +++ b/tools/testing/selftests/damon/huge_count_read_write.c @@ -8,6 +8,11 @@ #include <unistd.h> #include <stdio.h> +#pragma GCC diagnostic push +/* Ignore read(2) overflow and write(2) overread compile warnings */ +#pragma GCC diagnostic ignored "-Wstringop-overread" +#pragma GCC diagnostic ignored "-Wstringop-overflow" + void write_read_with_huge_count(char *file) { int filedesc = open(file, O_RDWR); @@ -27,6 +32,8 @@ void write_read_with_huge_count(char *file) close(filedesc); } +#pragma GCC diagnostic pop + int main(int argc, char *argv[]) { if (argc != 2) {