Message ID | 20231027-ethtool_puts_impl-v3-2-3466ac679304@google.com |
---|---|
State | Handled Elsewhere |
Headers | show
Return-Path: <intel-wired-lan-bounces@osuosl.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=s+w73sRs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJy6b6TdKz1yQ6 for <incoming@patchwork.ozlabs.org>; Tue, 31 Oct 2023 02:36:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 27BDB7097E; Mon, 30 Oct 2023 15:36:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 27BDB7097E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1698680182; bh=OtBqUijJPjJsusd3UZz8ZOlNZhvRfEsYLo40bckZva8=; h=Date:In-Reply-To:References:From:To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=s+w73sRsJz5gLbRuDQtSdGriYBDVKdwEoJvAc2wXqHI7VZf64DD3KCWtcA2kqYfkv LEzwXUulsj72GhsA/W80exPtFZtZmdrN4cAD1K+/T9PCoVVhLPnL0v/oFaWhTZ8YWS dF0TNH5o9Mv4FYKqyowWw+ofhVj4cejEkyoRVAh7k/s1A5AoJWWnWxKaR8UDZbH4pR uCvnjXZm6THNbVATKcqHL0FQ62r2FIbllD798LchBilMAOg76DkPx8uczOcMRVKhG/ ibEjV2Ldr1WmjS7Bk6vPcxCPjEXVG5zbhSGfJ+jg19yCUN6pmf3rqwXJXdBfyFuTRW Bd2wFa+CqGKmw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LbgPBlRrDRwS; Mon, 30 Oct 2023 15:36:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id EA5A570A78; Mon, 30 Oct 2023 15:36:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org EA5A570A78 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 0DEF81BF4E7 for <intel-wired-lan@lists.osuosl.org>; Fri, 27 Oct 2023 22:05:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C88DA709E3 for <intel-wired-lan@lists.osuosl.org>; Fri, 27 Oct 2023 22:05:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C88DA709E3 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v3wa4xlIgZPa for <intel-wired-lan@lists.osuosl.org>; Fri, 27 Oct 2023 22:05:40 +0000 (UTC) Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by smtp3.osuosl.org (Postfix) with ESMTPS id CBC9F709D0 for <intel-wired-lan@lists.osuosl.org>; Fri, 27 Oct 2023 22:05:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CBC9F709D0 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a7ed6903a6so22312937b3.2 for <intel-wired-lan@lists.osuosl.org>; Fri, 27 Oct 2023 15:05:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698444339; x=1699049139; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DdSXo05ZDTrQ0bolpnGX21EQgcBZaNy4lNpYoejJ8s8=; b=l+W4iuTB6csu0qVqpbefA5fiNuhKREUum4IQOkCG1c+ldpuwCjgFEdbLlhg1tLr+XV ScTAHy2CPR4xCGGuTDulb+p63d3mFcWAsxluYCcUEkMD4Hs1usRKVh1lSS0atr3qEDbP szLghY2nQqYv5WQOsGU/tFIbMgonJULdcELC+27T82K+AdMFq3RXNlYkv1SgBzJIr3x/ /AfN1DDno6q+sMG6LRJesX2h9pVwaVQAtTLpxbj8S30gHT0d61LvjZ2q+14hNXkAhnAn C4OFEmFkp2xg4iuI40rYpTb05jCIAwMw0g7GD2QRcf2dME9r8kgRiKJaUXoPmi8B3Vv7 oKdA== X-Gm-Message-State: AOJu0Yw3aYMcRRMTwKBlC4F3CGlrH9t4A8qSy3xNxiP7dqFR+3arlTMF xC0JpMSHe5LoB+/0hZsgfG/27f6odNr5/iKxxg== X-Google-Smtp-Source: AGHT+IEGanE/VPWiVGsYQnojjV2LR5zrl1qUYV/9Hzl9G6z+NxdeOgXz6WlWY7Ge6EIQf809mb8uIRPVcG/rsXoCAQ== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6902:1746:b0:d9a:59cb:8bed with SMTP id bz6-20020a056902174600b00d9a59cb8bedmr69382ybb.5.1698444338644; Fri, 27 Oct 2023 15:05:38 -0700 (PDT) Date: Fri, 27 Oct 2023 22:05:34 +0000 In-Reply-To: <20231027-ethtool_puts_impl-v3-0-3466ac679304@google.com> Mime-Version: 1.0 References: <20231027-ethtool_puts_impl-v3-0-3466ac679304@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1698444334; l=1990; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=Peahw3CmOtnUj2I89Tjap4JSwacXUbTFJpotNKfpIAo=; b=/dV8JH6sg2K0SMzdRYoIByKAm/hZGtV2i2RyZ0hRiSo1vOQmFG+LMPEoIUTIwPdSxZVjgBWW9 AOzrjCPUG+eCexFWJvZZE9e0rOdmAbkRvivrtrYWEohlds40p4HoDCE X-Mailer: b4 0.12.3 Message-ID: <20231027-ethtool_puts_impl-v3-2-3466ac679304@google.com> From: Justin Stitt <justinstitt@google.com> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shay Agroskin <shayagr@amazon.com>, Arthur Kiyanovski <akiyano@amazon.com>, David Arinzon <darinzon@amazon.com>, Noam Dagan <ndagan@amazon.com>, Saeed Bishara <saeedb@amazon.com>, Rasesh Mody <rmody@marvell.com>, Sudarsana Kalluru <skalluru@marvell.com>, GR-Linux-NIC-Dev@marvell.com, Dimitris Michailidis <dmichail@fungible.com>, Yisen Zhuang <yisen.zhuang@huawei.com>, Salil Mehta <salil.mehta@huawei.com>, Jesse Brandeburg <jesse.brandeburg@intel.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, Louis Peens <louis.peens@corigine.com>, Shannon Nelson <shannon.nelson@amd.com>, Brett Creeley <brett.creeley@amd.com>, drivers@pensando.io, "K. Y. Srinivasan" <kys@microsoft.com>, Haiyang Zhang <haiyangz@microsoft.com>, Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>, Ronak Doshi <doshir@vmware.com>, VMware PV-Drivers Reviewers <pv-drivers@vmware.com>, Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>, Dwaipayan Ray <dwaipayanray1@gmail.com>, Lukas Bulwahn <lukas.bulwahn@gmail.com>, Hauke Mehrtens <hauke@hauke-m.de>, Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vladimir Oltean <olteanv@gmail.com>, " =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= " <arinc.unal@arinc9.com>, Daniel Golle <daniel@makrotopia.org>, Landen Chao <Landen.Chao@mediatek.com>, DENG Qingfang <dqfext@gmail.com>, Sean Wang <sean.wang@mediatek.com>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Linus Walleij <linus.walleij@linaro.org>, " =?utf-8?q?Alvin_=C5=A0ipraga?= " <alsi@bang-olufsen.dk>, Wei Fang <wei.fang@nxp.com>, Shenwei Wang <shenwei.wang@nxp.com>, Clark Wang <xiaoning.wang@nxp.com>, NXP Linux Team <linux-imx@nxp.com>, Lars Povlsen <lars.povlsen@microchip.com>, Steen Hegelund <Steen.Hegelund@microchip.com>, Daniel Machon <daniel.machon@microchip.com>, UNGLinuxDriver@microchip.com, Jiawen Wu <jiawenwu@trustnetic.com>, Mengyuan Lou <mengyuanlou@net-swift.com>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com> X-Mailman-Approved-At: Mon, 30 Oct 2023 15:35:00 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698444339; x=1699049139; darn=lists.osuosl.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DdSXo05ZDTrQ0bolpnGX21EQgcBZaNy4lNpYoejJ8s8=; b=OsRN9STSKr5+9Xms3YoE0GrX50jJSw1YwHQOFQ/IpT9lthmyy4rFI6JbGNINrcaTZy te/GqK3Kg2cYv9yYqwtxAfQoHvUlw03veqHxLoHgYNBBa1tAG0B8zUmEq9jyT1WfXgGp lujKeJlnoyPY2eUogziu6kfY/irCqm+oS6NYMhgCGepYCzhui7UPVkVmsmnfNLkLek4F 5VtngrWwBuUDiTHaiK6LPZXFofJzvuEpP1AhrIdQk5ItSyKfjjz0J/P01c+gr2o7zeqJ +jweqipDZcKqJyizCsGfQ/w7lXfXYjm7VOQJEwdQCXFahapu6e39jW3/M7hCbLy85HWF B9TQ== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=OsRN9STS Subject: [Intel-wired-lan] [PATCH net-next v3 2/3] checkpatch: add ethtool_sprintf rules X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development <intel-wired-lan.osuosl.org> List-Unsubscribe: <https://lists.osuosl.org/mailman/options/intel-wired-lan>, <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe> List-Archive: <http://lists.osuosl.org/pipermail/intel-wired-lan/> List-Post: <mailto:intel-wired-lan@osuosl.org> List-Help: <mailto:intel-wired-lan-request@osuosl.org?subject=help> List-Subscribe: <https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe> Cc: linux-hyperv@vger.kernel.org, Kees Cook <keescook@chromium.org>, netdev@vger.kernel.org, Nick Desaulniers <ndesaulniers@google.com>, linux-kernel@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, oss-drivers@corigine.com, intel-wired-lan@lists.osuosl.org, Justin Stitt <justinstitt@google.com>, linux-mediatek@lists.infradead.org, bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" <intel-wired-lan-bounces@osuosl.org> |
Series |
ethtool: Add ethtool_puts()
|
expand
|
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7d16f863edf1..9369ce1d15c5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7020,6 +7020,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("PREFER_ETHTOOL_PUTS", + "Prefer ethtool_puts over ethtool_sprintf with only two arguments\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\bethtool_sprintf\s*\(\s*($FuncArg)\s*,\s*($FuncArg)/ethtool_puts($1, $7)/; + } + } + + # 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("PREFER_ETHTOOL_PUTS", + "Prefer ethtool_puts over ethtool_sprintf with standalone \"%s\" specifier\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\bethtool_sprintf\s*\(\s*($FuncArg)\s*,\s*"\%s"\s*,\s*($FuncArg)/ethtool_puts($1, $7)/; + } + } + + # typecasts on min/max could be min_t/max_t if ($perl_version_ok && defined $stat &&
Add some warnings for using ethtool_sprintf() where a simple ethtool_puts() would suffice. The two cases are: 1) Use ethtool_sprintf() with just two arguments: | ethtool_sprintf(&data, driver[i].name); or 2) Use ethtool_sprintf() with a standalone "%s" fmt string: | ethtool_sprintf(&data, "%s", driver[i].name); The former may cause -Wformat-security warnings while the latter is just not preferred. Both are safely in the category of warnings, not errors. Signed-off-by: Justin Stitt <justinstitt@google.com> --- scripts/checkpatch.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)