Skip to content

Commit

Permalink
drivers: base: swnode: remove need for a temporary string for the nod…
Browse files Browse the repository at this point in the history
…e name

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>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Colin Ian King authored and Rafael J. Wysocki committed Dec 11, 2018
1 parent caf35cd commit d84f18d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/base/swnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit d84f18d

Please sign in to comment.