mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: cgel.zte@gmail.com, kartilak@cisco.com
Cc: sebaddel@cisco.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jing Yao <yao.jing2@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] scsi: snic: Replace snprintf in show functions with   sysfs_emit
Date: Sun, 07 Nov 2021 08:13:08 -0800	[thread overview]
Message-ID: <b3961ecdf78e7f88a467650638e5935ea413bb8f.camel@perches.com> (raw)
In-Reply-To: <20211105081454.76950-1-yao.jing2@zte.com.cn>

On Fri, 2021-11-05 at 08:14 +0000, cgel.zte@gmail.com wrote:
> From: Jing Yao <yao.jing2@zte.com.cn>
> 
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
> WARNING use scnprintf or sprintf
> 
> Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
> sense.
[]
> diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c
[]
> @@ -37,7 +37,7 @@ snic_show_state(struct device *dev,
>  {
>  	struct snic *snic = shost_priv(class_to_shost(dev));
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n",
> +	return sysfs_emit(buf, "%s\n",
>  			snic_state_str[snic_get_state(snic)]);
>  }

when you do these, please consider the ability to rewrap to 80 columns.

	return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]);

> @@ -59,7 +59,7 @@ snic_show_link_state(struct device *dev,
>  	if (snic->config.xpt_type == SNIC_DAS)
>  		snic->link_status = svnic_dev_link_status(snic->vdev);
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n",
> +	return sysfs_emit(buf, "%s\n",
>  			(snic->link_status) ? "Link Up" : "Link Down");

And maintain parenthesis alignment

	return sysfs_emit(buf, "%s\n",
 			  snic->link_status ? "Link Up" : "Link Down");

or maybe

	return sysfs_emit(buf, "Link %s\n", snic->link_status ? "Up" : "Down");


      reply	other threads:[~2021-11-07 16:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  8:14 cgel.zte
2021-11-07 16:13 ` Joe Perches [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=b3961ecdf78e7f88a467650638e5935ea413bb8f.camel@perches.com \
    --to=joe@perches.com \
    --cc=cgel.zte@gmail.com \
    --cc=jejb@linux.ibm.com \
    --cc=kartilak@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sebaddel@cisco.com \
    --cc=yao.jing2@zte.com.cn \
    --cc=zealci@zte.com.cn \
    /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®