public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <mani@kernel.org>
To: Wan Jiabing <wanjiabing@vivo.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
	Hemant Kumar <quic_hemantk@quicinc.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jeffrey Hugo <quic_jhugo@quicinc.com>,
	Bhaumik Bhatt <bbhatt@codeaurora.org>,
	Paul Davey <paul.davey@alliedtelesis.co.nz>,
	Kees Cook <keescook@chromium.org>,
	mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bus: mhi: replace snprintf with sysfs_emit
Date: Wed, 27 Apr 2022 15:52:06 +0530	[thread overview]
Message-ID: <20220427102206.GD2536@thinkpad> (raw)
In-Reply-To: <20220426125902.681258-1-wanjiabing@vivo.com>

On Tue, Apr 26, 2022 at 08:58:59PM +0800, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/bus/mhi/host/init.c:89:8-16: WARNING: use scnprintf or sprintf
> 
> Use sysfs_emit and sysfs_emit_at instead of snprintf.
> 
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> ---
>  drivers/bus/mhi/host/init.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
> index cbb86b21063e..c137d55ccfa0 100644
> --- a/drivers/bus/mhi/host/init.c
> +++ b/drivers/bus/mhi/host/init.c
> @@ -86,7 +86,7 @@ static ssize_t serial_number_show(struct device *dev,
>  	struct mhi_device *mhi_dev = to_mhi_device(dev);
>  	struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
>  
> -	return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n",
> +	return sysfs_emit(buf, "Serial Number: %u\n",
>  			mhi_cntrl->serial_number);
>  }
>  static DEVICE_ATTR_RO(serial_number);
> @@ -100,9 +100,8 @@ static ssize_t oem_pk_hash_show(struct device *dev,
>  	int i, cnt = 0;
>  
>  	for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++)
> -		cnt += snprintf(buf + cnt, PAGE_SIZE - cnt,
> -				"OEMPKHASH[%d]: 0x%x\n", i,
> -				mhi_cntrl->oem_pk_hash[i]);
> +		cnt += sysfs_emit_at(buf, cnt, "OEMPKHASH[%d]: 0x%x\n",
> +				i, mhi_cntrl->oem_pk_hash[i]);
>  
>  	return cnt;
>  }
> -- 
> 2.35.3
> 
> 

      parent reply	other threads:[~2022-04-27 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 12:58 [PATCH] bus: mhi: replace snprintf with sysfs_emit Wan Jiabing
2022-04-26 21:26 ` Kees Cook
2022-04-27 10:22 ` Manivannan Sadhasivam [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=20220427102206.GD2536@thinkpad \
    --to=mani@kernel.org \
    --cc=bbhatt@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhi@lists.linux.dev \
    --cc=paul.davey@alliedtelesis.co.nz \
    --cc=quic_hemantk@quicinc.com \
    --cc=quic_jhugo@quicinc.com \
    --cc=wanjiabing@vivo.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