mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.ibm.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	intel-linux-scu@intel.com
Cc: artur.paszkiewicz@intel.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: isci: convert sysfs sprintf/snprintf family to sysfs_emit
Date: Wed, 03 Feb 2021 08:15:22 -0800	[thread overview]
Message-ID: <a6093892d7201fb940e14a571bc853829e704d0f.camel@linux.ibm.com> (raw)
In-Reply-To: <1612341806-30230-1-git-send-email-jiapeng.chong@linux.alibaba.com>

On Wed, 2021-02-03 at 16:43 +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warning:
> 
>  ./drivers/scsi/isci/init.c:140:8-16: WARNING: use scnprintf or
> sprintf.
> 
> Reported-by: Abaci Robot<abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/scsi/isci/init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
> index c452849..741a98e 100644
> --- a/drivers/scsi/isci/init.c
> +++ b/drivers/scsi/isci/init.c
> @@ -137,7 +137,7 @@ static ssize_t isci_show_id(struct device *dev,
> struct device_attribute *attr, c
>  	struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
>  	struct isci_host *ihost = container_of(sas_ha, typeof(*ihost),
> sas_ha);
>  
> -	return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id);
> +	return sysfs_emit(buf, "%d\n", ihost->id);

What's the point of doing this change?  We'd have to have 13,600 bit
integer types before this could ever possibly overflow and the
difference between snprintf and scnprintf actually matter from a
practical point of view.  Perhaps the coccinelle check should be
updated to account for these common impossible to overflow situations.

James



      reply	other threads:[~2021-02-03 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03  8:43 Jiapeng Chong
2021-02-03 16:15 ` James Bottomley [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=a6093892d7201fb940e14a571bc853829e704d0f.camel@linux.ibm.com \
    --to=jejb@linux.ibm.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=intel-linux-scu@intel.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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

all inboxes | Powered by JetHome®