Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1388418rdh; Fri, 27 Oct 2023 12:41:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXQyUTJkm2bDhVPD1lI0J+KiiuIT2sZpl4HU5GP7nBY/2j8sGYZXhqswN1VwxK6F3lDCDp X-Received: by 2002:a81:ae1c:0:b0:5a7:d9e6:8fd4 with SMTP id m28-20020a81ae1c000000b005a7d9e68fd4mr4091662ywh.12.1698435687122; Fri, 27 Oct 2023 12:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698435687; cv=none; d=google.com; s=arc-20160816; b=cysaArjFp6HMjdrKYiUGSwQOHYHX6xfC7D5Gm0W3NV3KHXvSJKDO6l8f1G9WPMnxVS l5vQjKer/YDgqfU761Pa+DdpS1QKvqQms2qVUW+AoTN3HZhaZU7+7TLhkCxPf8MMWQaF /wMCX2rW7NsfT9KgnFNVvX+6LHxpibiJAF3C5Hu4nnbZrcce7jOHXJZ5UBYwQ53oMOGJ uMneLk9Hf5DEo3qXIq9OFXp4QPTOVINY20x+a9DjyZKPwOUfnLHxulBkXFhdvZMFYvS+ ngKUgtk+uIG8/7BXXi/fJHnNzb1pcLnLvHee6rLyVFmDk7KBYMLHS3zYODYLmo7vxNbk YO9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=xzKQXsJ9PPJ95N5huUjFyALdgbkkeZmKhRTaQ99Yt+o=; fh=xfGFimo05YoVhrHfgu6rR8Wtg0VFjZT1ZxQY/OIvgXk=; b=MOUVWvz1KK8Lse1qIeHaApQovDAmtdjITPdYNjJ7x/fwgUzXsL/hNXYwu6bPNbBAf0 IK8tijJP2NgPeyTW8V/taIKIa9MdPxRgBK/C2rR3esGxrZllXrqsKgouOoGOjFUPUKNG puQRSW3kyfM5f64EW5KQoEPJZu7GL1TbNebqzbBuu+V99YvZ3ZUthNtFUZOdcA+IAE+9 mdQjJVyrjlQJTpIsLJQNC0HnPlQnlODDLZHEHm4TLQtCXVdFhHXf93T3o/y6r+l/KNCU qFcsI+vZRrp9mD2XnrKtZLtqWWZ59NtUrP70fQDXhLXG8vxk0b/HoMjRphJe2Dvq9mVD tIDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wKZpW2fw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id t199-20020a8183d0000000b005a7b3e505c2si3799073ywf.303.2023.10.27.12.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 12:41:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wKZpW2fw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 331948207708; Fri, 27 Oct 2023 12:41:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbjJ0Tk7 (ORCPT + 99 others); Fri, 27 Oct 2023 15:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbjJ0Tk5 (ORCPT ); Fri, 27 Oct 2023 15:40:57 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B4901B4 for ; Fri, 27 Oct 2023 12:40:53 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9c3aec5f326so747733666b.1 for ; Fri, 27 Oct 2023 12:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698435651; x=1699040451; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xzKQXsJ9PPJ95N5huUjFyALdgbkkeZmKhRTaQ99Yt+o=; b=wKZpW2fww82ttWeUy1lpz4jS6QO+dMf2wi5uMBR4ioUAJkaxBwfJwDdylta/HtSNzr wf6eDWx+upBsAk32+pi0zevJDyYABjRG8JU1jwfr0CBpKZYT1U+d0VaM2NitjhGiUpwW VeBSmfIjP/dVTwSUreGHdvuIGNtp8TvrjhgbGCgeraQyTlSl3onoR1GJkyWRCD9jXxhD x/dVJyenJeaoAwSCEWqvB4hCxajNDdXyFyrMJxNJQ8JEqKdQxbbtt1rJfX9MKZviWayz z77uLsAOK4RL6x9uhNLlBG0tsHf7ypU9mY/lkL7wFBAx3Uxfz0zO3qw6ke/EJsOlxu11 /hyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698435651; x=1699040451; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xzKQXsJ9PPJ95N5huUjFyALdgbkkeZmKhRTaQ99Yt+o=; b=D2y7EonRC4FdgbZ6f1NrIhYOWqv7AysbwhMbu4YBBXaiVVrWBxmMy0Mo/GV7he+8Vw dfkzpNt8cO9lXkcrRzz2AUiK1OfH6TnSLnbaKGFUHKd5Z469VzYd3PQrFflr1fwamWeU 5p9jzzBsbRZxJWPzQUECkkXPz+Cs4jdp+Q1GwL75qx90vM9s6iF+qc3y/12QtXC2aLy8 TIypGc7/RRs9hbCjUJlnT9lwW5g39x8ODyfu3s0Ac0LTpLQ5WlJbESGlU+yjp5abqlCD ZQMiWLKeia10SBLOV4D7NEGltUlrCP7y2KYVUlaXnybYb3xCIELdcsiwRPKvl7+nVsDD 5J8w== X-Gm-Message-State: AOJu0YyWSHo27i932MiJMrzpDjrbWAgcGkOeSZP/EEJwR+BG3mPM9DZ3 kYajIsXTxUjyuJ3UWMm1pw2VIoaQyVPOAbfYe76AmA== X-Received: by 2002:a17:907:2da3:b0:9c3:97d7:2c67 with SMTP id gt35-20020a1709072da300b009c397d72c67mr3978966ejc.25.1698435651329; Fri, 27 Oct 2023 12:40:51 -0700 (PDT) MIME-Version: 1.0 References: <20231026-ethtool_puts_impl-v2-0-0d67cbdd0538@google.com> <20231026-ethtool_puts_impl-v2-2-0d67cbdd0538@google.com> <8521c712250bcffce5c71e8d2b2574de786d4572.camel@perches.com> In-Reply-To: <8521c712250bcffce5c71e8d2b2574de786d4572.camel@perches.com> From: Justin Stitt Date: Fri, 27 Oct 2023 12:40:39 -0700 Message-ID: Subject: Re: [PATCH next v2 2/3] checkpatch: add ethtool_sprintf rules To: Joe Perches Cc: "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?B?QXLEsW7DpyDDnE5BTA==?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Linus Walleij , =?UTF-8?Q?Alvin_=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 , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Fri, 27 Oct 2023 12:41:10 -0700 (PDT) On Thu, Oct 26, 2023 at 3:39=E2=80=AFPM Joe Perches wrote= : > > 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 =3D~ /\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] =3D~ s/ethtool_sprintf\s*\(/ethtool_puts\(= /; > > + } > > + } > > + > > + # use $rawline because $line loses %s via sanitization an= d thus we can't match against it. > > + if ($rawline =3D~ /\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] =3D~ 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.cam= el@perches.com/ Ah, I didn't see you provided a diff in previous thread. Yeah you can push it but it's not really a standalone so perhaps I'll just steal the diff and wrap into v3? > > > + } > > + } > > + > > + > > # typecasts on min/max could be min_t/max_t > > if ($perl_version_ok && > > defined $stat && > > > Thanks Justin