intel-wired-lan.osuosl.org archive mirror
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Wang Liang <wangliang74@huawei.com>
Cc: <intel-wired-lan@lists.osuosl.org>, <anthony.l.nguyen@intel.com>,
	<andrew+netdev@lunn.ch>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<yuehaibing@huawei.com>, <zhangchangzhong@huawei.com>
Subject: Re: [Intel-wired-lan] [PATCH -next] i40e: Replace sscanf() with kstrtoint() in i40e_dbg_netdev_ops_write()
Date: Mon, 27 Oct 2025 10:40:15 +0100	[thread overview]
Message-ID: <ed0119ac-c69b-4840-afa4-ab77a195d36f@intel.com> (raw)
In-Reply-To: <20251025040735.558953-1-wangliang74@huawei.com>

On 10/25/25 06:07, Wang Liang wrote:
> Commit 9fcdb1c3c4ba ("i40e: remove read access to debugfs files")
> introduced some checkpatch warnings like this:
> 
>    WARNING: Prefer kstrto<type> to single variable sscanf
>    #240: FILE: drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1655:
>    +               cnt = sscanf(&cmd_buf[11], "%i", &vsi_seid);
> 
>    WARNING: Prefer kstrto<type> to single variable sscanf
>    #251: FILE: drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1676:
>    +               cnt = sscanf(&cmd_buf[4], "%i", &vsi_seid);
> 
>    total: 0 errors, 2 warnings, 0 checks, 194 lines checked
> 
> Function kstrtoint() provides better error detection, overflow protection,
> and consistent error handling than sscanf(). Replace sscanf() with
> kstrtoint() in i40e_dbg_netdev_ops_write() to silence the checkpatch
> warnings.
> 

sorry, we do not accept trivial patches, that are not a part of some
broader work related to the driver
https://docs.kernel.org/process/maintainer-netdev.html#clean-up-patches


> Signed-off-by: Wang Liang <wangliang74@huawei.com>
> ---
>   drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
> index c17b5d290f0a..2abd12b62509 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
> @@ -1604,7 +1604,7 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
>   	int bytes_not_copied;
>   	struct i40e_vsi *vsi;
>   	int vsi_seid;
> -	int i, cnt;
> +	int i, ret;
>   
>   	/* don't allow partial writes */
>   	if (*ppos != 0)
> @@ -1629,9 +1629,9 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
>   	if (strncmp(cmd_buf, "change_mtu", 10) == 0) {
>   		int mtu;
>   
> -		cnt = sscanf(&cmd_buf[11], "%i %i",
> +		ret = sscanf(&cmd_buf[11], "%i %i",
>   			     &vsi_seid, &mtu);
> -		if (cnt != 2) {
> +		if (ret != 2) {
>   			dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
>   			goto netdev_ops_write_done;
>   		}
> @@ -1652,8 +1652,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
>   		}
>   
>   	} else if (strncmp(cmd_buf, "set_rx_mode", 11) == 0) {
> -		cnt = sscanf(&cmd_buf[11], "%i", &vsi_seid);
> -		if (cnt != 1) {
> +		ret = kstrtoint(&cmd_buf[11], 0, &vsi_seid);
> +		if (ret) {
>   			dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
>   			goto netdev_ops_write_done;
>   		}
> @@ -1673,8 +1673,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
>   		}
>   
>   	} else if (strncmp(cmd_buf, "napi", 4) == 0) {
> -		cnt = sscanf(&cmd_buf[4], "%i", &vsi_seid);
> -		if (cnt != 1) {
> +		ret = kstrtoint(&cmd_buf[4], 0, &vsi_seid);
> +		if (ret) {
>   			dev_info(&pf->pdev->dev, "napi <vsi_seid>\n");
>   			goto netdev_ops_write_done;
>   		}


      reply	other threads:[~2025-10-27  9:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-25  4:07 [Intel-wired-lan] [PATCH -next] i40e: Replace sscanf() with kstrtoint() in i40e_dbg_netdev_ops_write() Wang Liang
2025-10-27  9:40 ` Przemek Kitszel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed0119ac-c69b-4840-afa4-ab77a195d36f@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wangliang74@huawei.com \
    --cc=yuehaibing@huawei.com \
    --cc=zhangchangzhong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).