linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next][RESEND] drivers: base: remove need for a temporary string for the node name
@ 2018-12-06 17:05 Colin King
  2018-12-17 11:39 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-12-06 17:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, linux-acpi
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the node name is being formatting into a temporary string
node_name, however, kobject_init_and_add allows one to format up
a node name, so use that instead. This removes the need for the
node_name string and also cleans up the following warning:

Fixes clang warning:
warning: format string is not a string literal (potentially
insecure) [-Wformat-security]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/base/swnode.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 9c63ec8d8ab4..306bb93287af 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -553,7 +553,6 @@ fwnode_create_software_node(const struct property_entry *properties,
 {
 	struct software_node *p = NULL;
 	struct software_node *swnode;
-	char node_name[20];
 	int ret;
 
 	if (parent) {
@@ -576,8 +575,6 @@ fwnode_create_software_node(const struct property_entry *properties,
 	}
 
 	swnode->id = ret;
-	sprintf(node_name, "node%d", swnode->id);
-
 	swnode->kobj.kset = swnode_kset;
 	swnode->fwnode.ops = &software_node_ops;
 
@@ -590,7 +587,7 @@ fwnode_create_software_node(const struct property_entry *properties,
 		list_add_tail(&swnode->entry, &p->children);
 
 	ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
-				   p ? &p->kobj : NULL, node_name);
+				   p ? &p->kobj : NULL, "node%d", swnode->id);
 	if (ret) {
 		kobject_put(&swnode->kobj);
 		return ERR_PTR(ret);
-- 
2.19.1


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

* Re: [PATCH][next][RESEND] drivers: base: remove need for a temporary string for the node name
  2018-12-06 17:05 [PATCH][next][RESEND] drivers: base: remove need for a temporary string for the node name Colin King
@ 2018-12-17 11:39 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2018-12-17 11:39 UTC (permalink / raw)
  To: Colin King
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-acpi,
	kernel-janitors, linux-kernel

On Thursday, December 6, 2018 6:05:57 PM CET Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the node name is being formatting into a temporary string
> node_name, however, kobject_init_and_add allows one to format up
> a node name, so use that instead. This removes the need for the
> node_name string and also cleans up the following warning:
> 
> Fixes clang warning:
> warning: format string is not a string literal (potentially
> insecure) [-Wformat-security]
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/base/swnode.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> index 9c63ec8d8ab4..306bb93287af 100644
> --- a/drivers/base/swnode.c
> +++ b/drivers/base/swnode.c
> @@ -553,7 +553,6 @@ fwnode_create_software_node(const struct property_entry *properties,
>  {
>  	struct software_node *p = NULL;
>  	struct software_node *swnode;
> -	char node_name[20];
>  	int ret;
>  
>  	if (parent) {
> @@ -576,8 +575,6 @@ fwnode_create_software_node(const struct property_entry *properties,
>  	}
>  
>  	swnode->id = ret;
> -	sprintf(node_name, "node%d", swnode->id);
> -
>  	swnode->kobj.kset = swnode_kset;
>  	swnode->fwnode.ops = &software_node_ops;
>  
> @@ -590,7 +587,7 @@ fwnode_create_software_node(const struct property_entry *properties,
>  		list_add_tail(&swnode->entry, &p->children);
>  
>  	ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
> -				   p ? &p->kobj : NULL, node_name);
> +				   p ? &p->kobj : NULL, "node%d", swnode->id);
>  	if (ret) {
>  		kobject_put(&swnode->kobj);
>  		return ERR_PTR(ret);
> 

Applied, thanks!



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

end of thread, other threads:[~2018-12-17 11:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06 17:05 [PATCH][next][RESEND] drivers: base: remove need for a temporary string for the node name Colin King
2018-12-17 11:39 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).