From patchwork Mon May 16 19:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Mateus Martins Araujo e Castro X-Patchwork-Id: 12851359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4B76C433F5 for ; Mon, 16 May 2022 19:20:46 +0000 (UTC) Received: from localhost ([::1]:44342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqgGr-0003KR-Jn for qemu-devel@archiver.kernel.org; Mon, 16 May 2022 15:20:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqgEg-0002P8-KW for qemu-devel@nongnu.org; Mon, 16 May 2022 15:18:31 -0400 Received: from [187.72.171.209] (port=56579 helo=outlook.eldorado.org.br) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqgEe-0008P2-NT for qemu-devel@nongnu.org; Mon, 16 May 2022 15:18:30 -0400 Received: from p9ibm ([10.10.71.235]) by outlook.eldorado.org.br over TLS secured channel with Microsoft SMTPSVC(8.5.9600.16384); Mon, 16 May 2022 16:18:19 -0300 Received: from eldorado.org.br (unknown [10.10.70.45]) by p9ibm (Postfix) with ESMTP id 006BD800048; Mon, 16 May 2022 16:18:18 -0300 (-03) From: "Lucas Mateus Castro(alqotel)" To: qemu-devel@nongnu.org Cc: Peter Maydell , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gan Qixin , "Lucas Mateus Castro(alqotel)" Subject: [RFC PATCH] scripts/checkpatch.pl: Change line limit warning Date: Mon, 16 May 2022 16:18:17 -0300 Message-Id: <20220516191817.136735-1-lucas.araujo@eldorado.org.br> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-OriginalArrivalTime: 16 May 2022 19:18:19.0254 (UTC) FILETIME=[B3891160:01D86959] X-Host-Lookup-Failed: Reverse DNS lookup failed for 187.72.171.209 (failed) Received-SPF: pass client-ip=187.72.171.209; envelope-from=lucas.araujo@eldorado.org.br; helo=outlook.eldorado.org.br X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, PDS_HP_HELO_NORDNS=0.659, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The QEMU documentation mentions that lines should be up to 80 characters and that the script checkpatch will warn at 100 characters, but the script warns at 80 characters and throw and error at 90, so this commit changes to warn at 100. As to why extend, the argument that resulted in the change of the docs was that trying to always wrap to 80 columns could result in less readable code, so sometimes not wrapping was the better choice and in those circumstances checkpatch could nudge people into creating less readable code. A 132 error limit is put to catch overly big lines. Based-on: 20201105154208.12442-1-ganqixin@huawei.com Signed-off-by: Lucas Mateus Castro(alqotel) --- Currently there's a disagreement between the checkpatch code and the documentation, this RFC just changes the checkpatch to match the documentation. But there was a discussion in 2020 as the best way to deal with this, some alternatives mentioned are: change the warning to remind people to not blindly wrap just because of the warning, change to warn at 90 columns (which would mean changing the column limit for the error as well). If any of those are preferred I'll send a next version updating the documentation as well as changing checkpatch.pl to the preferred behavior. --- scripts/checkpatch.pl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d900d18048..2c2d7b31ab 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1639,12 +1639,12 @@ sub process { if ($line =~ /^\+/ && !($line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && !($rawline =~ /^[^[:alnum:]]*https?:\S*$/) && - $length > 80) + $length > 100) { - if ($length > 90) { - ERROR("line over 90 characters\n" . $herecurr); + if ($length > 132) { + ERROR("line over 132 characters\n" . $herecurr); } else { - WARN("line over 80 characters\n" . $herecurr); + WARN("line over 100 characters\n" . $herecurr); } } @@ -1838,13 +1838,8 @@ sub process { #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; - # The length of the "previous line" is checked against 80 because it - # includes the + at the beginning of the line (if the actual line has - # 79 or 80 characters, it is no longer possible to add a space and an - # opening brace there) if ($#ctx == 0 && $ctx !~ /{\s*/ && - defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*\{/ && - defined($lines[$ctx_ln - 2]) && length($lines[$ctx_ln - 2]) < 80) { + defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*\{/) { ERROR("that open brace { should be on the previous line\n" . "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); }