All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit
@ 2021-11-03  8:23 cgel.zte
  2021-11-03  8:27 ` Johan Hovold
  2021-11-03  8:28 ` [PATCH] drivers: most: " Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: cgel.zte @ 2021-11-03  8:23 UTC (permalink / raw)
  To: johan; +Cc: gregkh, linux-kernel, Jing Yao, Zeal Robot

From: Jing Yao <yao.jing2@zte.com.cn>

coccicheck complains about the use of snprintf() in sysfs show
funcitons:
WARNING use scnprintf or sprintf

Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
sense.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
---
 drivers/most/most_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
index acabb7715b42..dccbec16000c 100644
--- a/drivers/most/most_usb.c
+++ b/drivers/most/most_usb.c
@@ -831,7 +831,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
 	int err;
 
 	if (sysfs_streq(name, "arb_address"))
-		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
+		return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
 
 	if (sysfs_streq(name, "arb_value"))
 		reg_addr = dci_obj->reg_addr;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit
  2021-11-03  8:23 [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit cgel.zte
@ 2021-11-03  8:27 ` Johan Hovold
  2021-11-04 11:45   ` [PATCH v2] " cgel.zte
  2021-11-03  8:28 ` [PATCH] drivers: most: " Greg KH
  1 sibling, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2021-11-03  8:27 UTC (permalink / raw)
  To: cgel.zte; +Cc: gregkh, linux-kernel, Jing Yao, Zeal Robot

On Wed, Nov 03, 2021 at 08:23:13AM +0000, cgel.zte@gmail.com wrote:
> From: Jing Yao <yao.jing2@zte.com.cn>
> 
> coccicheck complains about the use of snprintf() in sysfs show
> funcitons:
> WARNING use scnprintf or sprintf
> 
> Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
> sense.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>

Again, no need to include "drivers: " in the Subject, even if in this
case the single commit adding this file also got this wrong.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit
  2021-11-03  8:23 [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit cgel.zte
  2021-11-03  8:27 ` Johan Hovold
@ 2021-11-03  8:28 ` Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-11-03  8:28 UTC (permalink / raw)
  To: cgel.zte; +Cc: johan, linux-kernel, Jing Yao, Zeal Robot

On Wed, Nov 03, 2021 at 08:23:13AM +0000, cgel.zte@gmail.com wrote:
> From: Jing Yao <yao.jing2@zte.com.cn>
> 
> coccicheck complains about the use of snprintf() in sysfs show
> funcitons:
> WARNING use scnprintf or sprintf
> 
> Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
> sense.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>

This "robot" is not coccicheck.


> Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
> ---
>  drivers/most/most_usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
> index acabb7715b42..dccbec16000c 100644
> --- a/drivers/most/most_usb.c
> +++ b/drivers/most/most_usb.c
> @@ -831,7 +831,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
>  	int err;
>  
>  	if (sysfs_streq(name, "arb_address"))
> -		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
> +		return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
>  
>  	if (sysfs_streq(name, "arb_value"))
>  		reg_addr = dci_obj->reg_addr;
> -- 
> 2.25.1

Why did you only change one of the instances of this in this function
and not both?

Are you going to send a follow-on patch to change the other use of
snprintf() here?

Please do it all in one patch, and fix your "robot" to correctly notify
you of mistakes like this.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] most: replace snprintf in show functions with sysfs_emit
  2021-11-03  8:27 ` Johan Hovold
@ 2021-11-04 11:45   ` cgel.zte
  2021-11-08  9:50     ` Johan Hovold
  0 siblings, 1 reply; 6+ messages in thread
From: cgel.zte @ 2021-11-04 11:45 UTC (permalink / raw)
  To: johan; +Cc: cgel.zte, gregkh, linux-kernel, yao.jing2, zealci

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.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
---

Changes since v1:
 - Actually, the robot which is composed of lots of tools includes
   coccienlle.
 - Change the ignored snprintf().
 - Change the wrong Subject.

 drivers/most/most_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
index acabb7715b42..73258b24fea7 100644
--- a/drivers/most/most_usb.c
+++ b/drivers/most/most_usb.c
@@ -831,7 +831,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
 	int err;
 
 	if (sysfs_streq(name, "arb_address"))
-		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
+		return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
 
 	if (sysfs_streq(name, "arb_value"))
 		reg_addr = dci_obj->reg_addr;
@@ -843,7 +843,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
 	if (err < 0)
 		return err;
 
-	return snprintf(buf, PAGE_SIZE, "%04x\n", val);
+	return sysfs_emit(buf, "%04x\n", val);
 }
 
 static ssize_t value_store(struct device *dev, struct device_attribute *attr,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] most: replace snprintf in show functions with sysfs_emit
  2021-11-04 11:45   ` [PATCH v2] " cgel.zte
@ 2021-11-08  9:50     ` Johan Hovold
  2021-11-10  2:53       ` [PATCH v3] most: usb: " cgel.zte
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2021-11-08  9:50 UTC (permalink / raw)
  To: cgel.zte; +Cc: gregkh, linux-kernel, yao.jing2, zealci

On Thu, Nov 04, 2021 at 11:45:40AM +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.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
> ---
> 
> Changes since v1:
>  - Actually, the robot which is composed of lots of tools includes
>    coccienlle.
>  - Change the ignored snprintf().
>  - Change the wrong Subject.

Ok, this is much better, but note that there are a lot more instances
like this in the "most" subsystem which this patch is not addressing so
the patch prefix should really have been:

	"most: usb: ..."

since you're only handling the most usb driver.

>  drivers/most/most_usb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
> index acabb7715b42..73258b24fea7 100644
> --- a/drivers/most/most_usb.c
> +++ b/drivers/most/most_usb.c
> @@ -831,7 +831,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
>  	int err;
>  
>  	if (sysfs_streq(name, "arb_address"))
> -		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
> +		return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
>  
>  	if (sysfs_streq(name, "arb_value"))
>  		reg_addr = dci_obj->reg_addr;
> @@ -843,7 +843,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
>  	if (err < 0)
>  		return err;
>  
> -	return snprintf(buf, PAGE_SIZE, "%04x\n", val);
> +	return sysfs_emit(buf, "%04x\n", val);
>  }
>  
>  static ssize_t value_store(struct device *dev, struct device_attribute *attr,

Other than that, looks good:

Reviewed-by: Johan Hovold <johan@kernel.org>

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3] most: usb: replace snprintf in show functions with sysfs_emit
  2021-11-08  9:50     ` Johan Hovold
@ 2021-11-10  2:53       ` cgel.zte
  0 siblings, 0 replies; 6+ messages in thread
From: cgel.zte @ 2021-11-10  2:53 UTC (permalink / raw)
  To: johan; +Cc: cgel.zte, gregkh, linux-kernel, yao.jing2, zealci

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.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
---

Changes since v2:
 - Revise the inappropriate Subject.

 drivers/most/most_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
index acabb7715b42..73258b24fea7 100644
--- a/drivers/most/most_usb.c
+++ b/drivers/most/most_usb.c
@@ -831,7 +831,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
 	int err;
 
 	if (sysfs_streq(name, "arb_address"))
-		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
+		return sysfs_emit(buf, "%04x\n", dci_obj->reg_addr);
 
 	if (sysfs_streq(name, "arb_value"))
 		reg_addr = dci_obj->reg_addr;
@@ -843,7 +843,7 @@ static ssize_t value_show(struct device *dev, struct device_attribute *attr,
 	if (err < 0)
 		return err;
 
-	return snprintf(buf, PAGE_SIZE, "%04x\n", val);
+	return sysfs_emit(buf, "%04x\n", val);
 }
 
 static ssize_t value_store(struct device *dev, struct device_attribute *attr,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-10  2:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  8:23 [PATCH] drivers: most: replace snprintf in show functions with sysfs_emit cgel.zte
2021-11-03  8:27 ` Johan Hovold
2021-11-04 11:45   ` [PATCH v2] " cgel.zte
2021-11-08  9:50     ` Johan Hovold
2021-11-10  2:53       ` [PATCH v3] most: usb: " cgel.zte
2021-11-03  8:28 ` [PATCH] drivers: most: " Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.