Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp770070rdh; Thu, 26 Oct 2023 15:39:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAUVFPA4uHb2VM3cFg5hs6kxA6b9KKg3TarTY5d9BX6cFeJ1aCK+jXu/sIvka4YLdUkMWa X-Received: by 2002:a05:6808:1ce:b0:3b2:e77b:640d with SMTP id x14-20020a05680801ce00b003b2e77b640dmr760825oic.31.1698359957833; Thu, 26 Oct 2023 15:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698359957; cv=none; d=google.com; s=arc-20160816; b=PmPGxYgkWQQTXBTb8ZpJzWszcUoe+Ahu8c5lE5rHqiRBMzWsF6oMA9KYnGiGgKEw0J nqKQPZmqU1a+IynG6VrCsaS1Rh9k06/qrZZKdxP2gxoVlbpbkibVjK5c0/CwLLEwksPd F+wEKXIu8RknbL7QB35lNRFA9jok+cRmG1woHziHURAo1MEZcNKemo2UaH73dKjlwvgq 5SKXrtWU1XR0BhHSpWDdBZm8ZqDWF0WJd7XnXG6A9BjUF39E7xUvCwAVJcLSJaIfaaia rnCENQmbm7JCFCGGw0XVwkQncQPs669NvM+L2/x6Uzn8u9XnnoGmFU2jziXWrdcDuCSd 6GKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=U7FZFd+jSXg/kJNpJrLemG7GmwnXxPkSJpnug07o1n4=; fh=e0g5t6Z1DhICh5Jj2At5jEXJci8XjJX/HgrnT5g2Br8=; b=cvgdAxiUQwu8AKzrsIytKDyrLH6OINwvAWhs+Pnu/6/ASORE7RKUJa6zzyLsMh6ZMU k++uLzNtSJvOcl8wVayYg0aidzvbZpZp7p9MYRktd8oPiyyWtZMPlEKU6VZwtSEI1nJr sDoUqs63xgdCiLMlc9i1dFRyQ6avjLiuJeGdO2a2UuNk71oboQj4jjuvAKExSm7agr1f yPoMpMA9FudxXtbIb2zcJzidoI8WerLsGiTfBpMAiXox064zrEvoWhbtxT2RE24a9VPW +fAppEI+Pf/CU60F75bvzxLIe51cmtjZiGuBAUwlIHqHEFt7qh1A7gHg6e+7RHImiRs+ jofQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a3-20020a254d03000000b00d9abd69772bsi525085ybb.124.2023.10.26.15.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 899808269197; Thu, 26 Oct 2023 15:39:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344896AbjJZWjP convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Oct 2023 18:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjJZWjN (ORCPT ); Thu, 26 Oct 2023 18:39:13 -0400 Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D1E7CC; Thu, 26 Oct 2023 15:39:11 -0700 (PDT) Received: from omf03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EC899120CA5; Thu, 26 Oct 2023 22:39:08 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA id 229B46000C; Thu, 26 Oct 2023 22:38:40 +0000 (UTC) Message-ID: <8521c712250bcffce5c71e8d2b2574de786d4572.camel@perches.com> Subject: Re: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules From: Joe Perches To: Justin Stitt , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , Rasesh Mody , Sudarsana Kalluru , GR-Linux-NIC-Dev@marvell.com, Dimitris Michailidis , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Louis Peens , Shannon Nelson , Brett Creeley , drivers@pensando.io, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Ronak Doshi , VMware PV-Drivers Reviewers , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Hauke Mehrtens , Andrew Lunn , Florian Fainelli , Vladimir Oltean , =?UTF-8?Q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Linus Walleij , Alvin =?UTF-8?Q?=C5=A0ipraga?= , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , Lars Povlsen , Steen Hegelund , Daniel Machon , UNGLinuxDriver@microchip.com, Jiawen Wu , Mengyuan Lou , Heiner Kallweit , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Kees Cook , intel-wired-lan@lists.osuosl.org, oss-drivers@corigine.com, linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, bpf@vger.kernel.org Date: Thu, 26 Oct 2023 15:38:39 -0700 In-Reply-To: <20231026-ethtool_puts_impl-v2-2-0d67cbdd0538@google.com> References: <20231026-ethtool_puts_impl-v2-0-0d67cbdd0538@google.com> <20231026-ethtool_puts_impl-v2-2-0d67cbdd0538@google.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Rspamd-Queue-Id: 229B46000C X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Stat-Signature: mtojnbfkhmj945izba58at9t64m9az5b X-Rspamd-Server: rspamout08 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/UB5xXHbX1I6Iwr1/WX9S8fJXYcv2DOVQ= X-HE-Tag: 1698359919-976100 X-HE-Meta: U2FsdGVkX1/Amx6RsPXMmp/lJzH0XSfOupRJb1kmsjddDIYEwUvtXmlXvcoG0HQxgfJeu/bgjCSmBW9XNko/mFTeWhpzlQGj+sHcroC4+SQucDoul9/mW561AqHS3bN32ZhIbH4y4PO56Z7gmbgk+jEv1lNmijdnNQn2GDoTkX/tD06ZkKPHkXJTWWOiblBjoSzVelzS2tuc0jq7rbU2KN7wKu2c9SCdLcBX7eDcPHw0DYjtwdWRO7eI8BixY9+TH41p+q5lsfSnzBidMm8GWcRCTJkLQdvf6jjmqEDt8BcNB67WbPmIoEo21hk8mGqMRn8qjdO5KQuIvo+QRzi9TNWL/Qwj5lvUYAvGAivJpjz++odpOBd6Ml2HgJTXQ35CUCCg8zvynD3R6R7WDpQwYoliPG09jddatznky2vFjJO9MiTzTC/t5iwPcMcldvPAUeGRgklQ6A1GlziHr19N0w== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 26 Oct 2023 15:39:16 -0700 (PDT) On Thu, 2023-10-26 at 21:56 +0000, Justin Stitt wrote: > Add some warnings for using ethtool_sprintf() where a simple > ethtool_puts() would suffice. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -7011,6 +7011,25 @@ sub process { > "Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90\n" . $herecurr); > } > > +# ethtool_sprintf uses that should likely be ethtool_puts > + if ($line =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { > + if(WARN("ETHTOOL_SPRINTF", > + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && > + $fix) { > + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(/ethtool_puts\(/; > + } > + } > + > + # use $rawline because $line loses %s via sanitization and thus we can't match against it. > + if ($rawline =~ /\bethtool_sprintf\s*\(\s*$FuncArg\s*,\s*\"\%s\"\s*,\s*$FuncArg\s*\)/) { > + if(WARN("ETHTOOL_SPRINTF", > + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && > + $fix) { > + $fixed[$fixlinenr] =~ s/ethtool_sprintf\s*\(\s*(.*?),.*?,(.*?)\)/ethtool_puts\($1,$2)/; Thanks, but: This fix wouldn't work if the first argument was itself a function with multiple arguments. And this is whitespace formatted incorrectly. It: o needs a space after if o needs a space after the comma in the fix o needs to use the appropriate amount and tabs for indentation o needs alignment to open parentheses o the backslashes are not required in the fix block Do you want me to push what I wrote in the link below? https://lore.kernel.org/lkml/7eec92d9e72d28e7b5202f41b02a383eb28ddd26.camel@perches.com/ > + } > + } > + > + > # typecasts on min/max could be min_t/max_t > if ($perl_version_ok && > defined $stat && >