[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SJ0PR11MB58966A005DB6136D106A1DA6C3712@SJ0PR11MB5896.namprd11.prod.outlook.com>
Date: Thu, 18 Jan 2024 23:24:51 +0000
From: "Karan Tilak Kumar (kartilak)" <kartilak@...co.com>
To: Li Zhijian <lizhijian@...itsu.com>,
"linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
CC: "Satish Kharat (satishkh)" <satishkh@...co.com>,
"Sesidhar Baddela
(sebaddel)" <sebaddel@...co.com>,
"James E.J. Bottomley"
<jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
"linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>
Subject: RE: [PATCH 22/42] drivers/scsi/fnic: Convert snprintf to sysfs_emit
On Monday, January 15, 2024 8:52 PM, Li Zhijian <lizhijian@...itsu.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/scsi/fnic/fnic_attrs.c:17:8-16: WARNING: please use
> > sysfs_emit
> > ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use
> > sysfs_emit
> > ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use
> > sysfs_emit
>
> No functional change intended
>
> CC: Satish Kharat <satishkh@...co.com>
> CC: Sesidhar Baddela <sebaddel@...co.com>
> CC: Karan Tilak Kumar <kartilak@...co.com>
> CC: "James E.J. Bottomley" <jejb@...ux.ibm.com>
> CC: "Martin K. Petersen" <martin.petersen@...cle.com>
> CC: linux-scsi@...r.kernel.org
> Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
> ---
> drivers/scsi/fnic/fnic_attrs.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c index a61e0c5e6506..0c5e57c7e322 100644
> --- a/drivers/scsi/fnic/fnic_attrs.c
> +++ b/drivers/scsi/fnic/fnic_attrs.c
> @@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev,
> struct fc_lport *lp = shost_priv(class_to_shost(dev));
> struct fnic *fnic = lport_priv(lp);
>
> - return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
> + return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
> }
>
> static ssize_t fnic_show_drv_version(struct device *dev,
> struct device_attribute *attr, char *buf) {
> - return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
> + return sysfs_emit(buf, "%s\n", DRV_VERSION);
> }
>
> static ssize_t fnic_show_link_state(struct device *dev, @@ -28,8 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev, {
> struct fc_lport *lp = shost_priv(class_to_shost(dev));
>
> - return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
> - ? "Link Up" : "Link Down");
> + return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link
> +Down");
> }
>
> static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
> --
> 2.29.2
>
>
Looks good to me.
Reviewed-by: Karan Tilak Kumar <kartilak@...co.com>
Regards,
Karan
Powered by blists - more mailing lists