netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
To: Li Zhijian <lizhijian@fujitsu.com>
Cc: linux-kernel@vger.kernel.org,
	Richard Cochran <richardcochran@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 15/42] drivers/ptp: Convert snprintf to sysfs_emit
Date: Mon, 15 Jan 2024 21:01:22 -0800	[thread overview]
Message-ID: <875xztzx3e.fsf@nvidia.com> (raw)
In-Reply-To: <20240116045151.3940401-13-lizhijian@fujitsu.com>

On Tue, 16 Jan, 2024 12:51:24 +0800 Li Zhijian <lizhijian@fujitsu.com> wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Richard Cochran <richardcochran@gmail.com>
> CC: netdev@vger.kernel.org
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
>  drivers/ptp/ptp_sysfs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
> index f7a499a1bd39..49737ed6ef5f 100644
> --- a/drivers/ptp/ptp_sysfs.c
> +++ b/drivers/ptp/ptp_sysfs.c
> @@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev,
>  {
>  	struct ptp_clock *ptp = dev_get_drvdata(dev);
>  
> -	return snprintf(page, PAGE_SIZE - 1, "%d\n",
> -			ptp->info->getmaxphase(ptp->info));
> +	return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info));
>  }
>  static DEVICE_ATTR_RO(max_phase_adjustment);

I authored the lines that are being changed here, so figured I should
provide my review. Doesn't PTP_SHOW_INT in the same file also use
snprintf in the same manner and should be changed to sysfs_emit?

--
Thanks,

Rahul Rameshbabu

  reply	other threads:[~2024-01-16  5:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16  4:10 [PATCH 00/42] Fix coccicheck warnings Li Zhijian
     [not found] ` <20240116045151.3940401-1-lizhijian@fujitsu.com>
2024-01-16  4:51   ` [PATCH 15/42] drivers/ptp: Convert snprintf to sysfs_emit Li Zhijian
2024-01-16  5:01     ` Rahul Rameshbabu [this message]
2024-01-16  5:52       ` Zhijian Li (Fujitsu)
2024-01-16 15:33     ` Jakub Kicinski
2024-01-17  5:39       ` Zhijian Li (Fujitsu)
2024-02-06  2:07 ` (subset) [PATCH 00/42] Fix coccicheck warnings Martin K. Petersen

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=875xztzx3e.fsf@nvidia.com \
    --to=rrameshbabu@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.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).