Message ID | tencent_CF837EA1B8AC81CB7715E85797510D441E07@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 l7csp153237wru; Thu, 10 Nov 2022 05:41:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM4OczB8B4/tNzoOp7t4QoVZ3BWhDzJ2NNIRa8djVjYKdUWbPWBJX+msZXuSx3KmPudxpWe6 X-Received: by 2002:a17:90a:7c47:b0:212:ea80:8b02 with SMTP id e7-20020a17090a7c4700b00212ea808b02mr65772038pjl.60.1668087696190; Thu, 10 Nov 2022 05:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668087696; cv=none; d=google.com; s=arc-20160816; b=LnjbOwJzq5wwgFD/svss0E33WeGq+9cDjWRkE2BhS61Ft6KMch9gvkJ346XiXkXMLe zXOmkICKzG6ioMZw8Ri5s7rWesduXmqNfN4OaRo51Li601TGoe94NuYS0fUEflchsj1x tUf7WnNfzl6Km4VLzlBacpMicI6s9k48hX5UZBYgk6tIZj9AG4EGBuZDda8xJhOqYFTt p+sAIsX66XrGMlUKDYZaKZFMQv1sA31sg/covdmLcgDx9LKcNq907QbD4J9FuN7YL1H9 MMe84L5Xk5098zECZo/S3+C5vMf976yC1wByy7cpZZ5W4I+eQ9jge8AsI+WBAzOE97ZG E5Nw== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=eY7h4fhFTfwfC9Nhrrjq36hOBtSMKTwHQ0XH45yPyYA=; b=qzhrQZQs/D2u09JcCLByoxvukX04ckgrVM/aFJtZky7xChgkkRbXB9xMpC8fDcxGx4 /5FR18gUs/cwgQKuOqS1fHVFtKm9SvQJnXnpqCcsqt7nYFCPGGAEVCzeiP8nuKsHBznf v+RYa8db9f6IiW3Du8KS/Xb7RgI/CCyG3vmLnu6M/3OLsRiO4cAi4EggVYVuXaNw4GVf fAvlFozy+LbvpU7At68retQH2U8DA1YUBiQSzZ4VyLOE3s5vJWL7SKRNtbBpAL2A2ma8 LQ57AfPCHalVjNREE0DRBufZ8ZCYIOMm/NVn7tb+n+xyjBDLoY5U6hrLC5s56Wes9VXG CriA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=jW0xUs58; 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 g11-20020a170902934b00b00186e8526793si18811154plp.143.2022.11.10.05.41.16; Thu, 10 Nov 2022 05:41:36 -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=jW0xUs58; 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 S230359AbiKJNec (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 08:34:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiKJNeb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 08:34:31 -0500 Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81B38B850; Thu, 10 Nov 2022 05:34:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1668087266; bh=eY7h4fhFTfwfC9Nhrrjq36hOBtSMKTwHQ0XH45yPyYA=; h=From:To:Cc:Subject:Date; b=jW0xUs58Ma6Hzl6RLY2VbdzV26A1lw7/ViwGucjFGDXxA7py2Wcytu04lzpLdXSY6 hqd4jp5p9p5XJeTzCF8xAGB17RGUIwlSzlTTUeFmv+6DgflAwvoShTzeH0775O9uuD CBGLr2MYmGDJrL6DyY2yRUCxxaiDzhUHvdHDml+I= Received: from localhost.localdomain ([111.199.191.46]) by newxmesmtplogicsvrszc1-0.qq.com (NewEsmtp) with SMTP id 8972E81A; Thu, 10 Nov 2022 21:34:23 +0800 X-QQ-mid: xmsmtpt1668087263te4c0uqb5 Message-ID: <tencent_CF837EA1B8AC81CB7715E85797510D441E07@qq.com> X-QQ-XMAILINFO: MCKLvPxUEMECfDLJ42pOPtys1rQM8Gm7uOj/ovE65laisNHzQg0mOva9tNmM3V lxbEHMODtvFjD+2wfQta0kK+RYHMKDmYM0kwPDGYMhuG2IJEY+Yidi7wGU3bR40D5B9Qx/DBZ1Mk K05fuzfEU28zJUDc5gdULKgHlMkZFX4tQvxZglqhgSgMtDcbgkYGeWB9OaZ/NAeFBn7BQlQ+ybRD Uw0f3WEiAd03jBWeYU0t1EGpUNPwBnchI9oBQXujRpWJKkSPLPO3lHCA+mqeMXXhxs39fKgGFtMj m3uEdIB6gDyy1RNJKArlBau7L/Du73VfwP6hmwh/Ussgr9sLNFQKkLo5iidcI8eFLBLzFeMHzZzq Vbr38x8oUQazxYWvICYz9VYmuAYw5IrflhQNrPqMhh2ixW/87qJI8cdkcuvEWPJ8jTB+2u9ozAZk FWwPgRAj0KVjqgigCmvqFEKC9fx8Da/fqXqST3k3ehSrkgJkZVb4zdEqtLZwQ5BMYAZYmYd0BWiK oEeLCLGAPbKghD94iRxd15WZGr7ylK7HFkAPhij2gdZQqFx+qKvcQm2NhITvsp53S5AzneXze5al MUmZJKmmnN6gb9kYDfvN7Q2moGTWh6QLOGnR4RqOpXqal9WPBzITW8gY/DU2flsr91lBcflX6t8d uvMWj3qBsyVq3wtdGSS/gzU2430tq6lUTh5UXTPOqcSB7pMPozZllCDA0lk6TKZXq6vbpFx1v3o6 HzInbE65NyRFfmRGYaB7Xe4auglqj2qk/UGVXCFw62ZQ8eeOAsgx4d5htDWdsYxQrXACgBGRDbsq rbw4B0XOK5mNKJOl/7kW3VOtIhVUdPsMP0niDNlJr/BFPETQfngVj8wrShvgpTLaHFEeLWlsa1nI lj/MHlvZWVzmy+PN20XQgPuX/+BnoGhr2tktr5PZAgRdeTKcAOsw5mc3UEFbmNW+MRjaWD0Q7FeO KmpKJOOxzoH/Krn8lcl9lqYmUDsxVpzNFzMKC8mrysvbu+8c5VJA== From: Rong Tao <rtoax@foxmail.com> To: sj@kernel.org Cc: Rong Tao <rongtao@cestc.cn>, Shuah Khan <shuah@kernel.org>, damon@lists.linux.dev (open list:DATA ACCESS MONITOR), linux-mm@kvack.org (open list:DATA ACCESS MONITOR), linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] selftests/damon: Fix unnecessary compilation warnings Date: Thu, 10 Nov 2022 21:34:18 +0800 X-OQ-MSGID: <20221110133418.17054-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.31.1 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,RCVD_IN_MSPIKE_H2,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?1749116724319628472?= |
Series |
selftests/damon: Fix unnecessary compilation warnings
|
|
Commit Message
Rong Tao
Nov. 10, 2022, 1:34 p.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/ gcc huge_count_read_write.c -o /home/sd/Git/linux/tools/testing/selftests/damon/huge_count_read_write huge_count_read_write.c: In function ‘write_read_with_huge_count’: huge_count_read_write.c:23:9: warning: ‘write’ reading 4294967295 bytes from a region of size 1 [-Wstringop-overread] 23 | write(filedesc, "", 0xfffffffful); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from huge_count_read_write.c:8: /usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘access (read_only, 2, 3)’ 378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur | ^~~~~ huge_count_read_write.c:25:15: warning: ‘read’ writing 4294967295 bytes into a region of size 25 overflows the destination [-Wstringop-overflow=] 25 | ret = read(filedesc, buf, 0xfffffffful); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ huge_count_read_write.c:14:14: note: destination object ‘buf’ of size 25 14 | char buf[25]; | ^~~ In file included from huge_count_read_write.c:8: /usr/include/unistd.h:371:16: note: in a call to function ‘read’ declared with attribute ‘access (write_only, 2, 3)’ 371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur | ^~~~ Signed-off-by: Rong Tao <rongtao@cestc.cn> --- tools/testing/selftests/damon/huge_count_read_write.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
Cc-ing Yuanchu Xie. Hi Rong, On Thu, 10 Nov 2022 21:34:18 +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/ > gcc huge_count_read_write.c -o /home/sd/Git/linux/tools/testing/selftests/damon/huge_count_read_write 'checkpatch.pl' complains: WARNING: use relative pathname instead of absolute in changelog text #20: gcc huge_count_read_write.c -o /home/sd/Git/linux/tools/testing/selftests/damon/huge_count_read_write Also, could we add four spaces indent for code snippet/command outputs like above? > huge_count_read_write.c: In function ‘write_read_with_huge_count’: > huge_count_read_write.c:23:9: warning: ‘write’ reading 4294967295 bytes from a region of size 1 [-Wstringop-overread] > 23 | write(filedesc, "", 0xfffffffful); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from huge_count_read_write.c:8: > /usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘access (read_only, 2, 3)’ > 378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur > | ^~~~~ > huge_count_read_write.c:25:15: warning: ‘read’ writing 4294967295 bytes into a region of size 25 overflows the destination [-Wstringop-overflow=] > 25 | ret = read(filedesc, buf, 0xfffffffful); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > huge_count_read_write.c:14:14: note: destination object ‘buf’ of size 25 > 14 | char buf[25]; > | ^~~ > In file included from huge_count_read_write.c:8: > /usr/include/unistd.h:371:16: note: in a call to function ‘read’ declared with attribute ‘access (write_only, 2, 3)’ > 371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur > | ^~~~ > > 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" > +#pragma GCC diagnostic ignored "-Wstringop-overflow" > + Thank you for sending this patch! However, there was a similar patch from Yuanchu[1], and this causes another warning for old gcc[2] that I use (9.4.0), like below. 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’ As mentioned as a reply to Yuanchu's patch, I'd slightly prefer making it silent for both new and old compilers than this approach, but no strong opinion from my side. Yuanchu and Shuah, do you have some opinion? [1] https://lore.kernel.org/lkml/CAJj2-QE4ee=N9wYXVQc6gyZYC3zgAsWVwWJ7DMaS2B9q2WqBHw@mail.gmail.com/ [2] https://lore.kernel.org/lkml/20220504184537.130085-1-sj@kernel.org/ [3] https://lore.kernel.org/lkml/20220517160417.1096-1-sj@kernel.org/ Thanks, SJ > 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 > >
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) {