Skip to contentSkip to conversation

driver/core: Fix various warnings due to dev_set_name() usage

PATCH In review Benjamin Herrenschmidt 2 participants 3 messages Jun 17, 2009 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver/core: Fix various warnings due to dev_set_name() usage

gcc is too smart, we get:

drivers/base/core.c: In function ‘device_add’:
drivers/base/core.c:877: warning: format not a string literal and no format arguments drivers/base/core.c: In function ‘__root_device_register’:
drivers/base/core.c:1274: warning: format not a string literal and no format arguments

With 4.3.3 and later. This fixes a bunch of them in drivers/base

---

There's still more of these elsewhere in the tree and I may send patches to fix them some day but for now, this takes care of the driver core.

drivers/base/core.c +2 -2
Index: linux-work/drivers/base/core.c
===================================================================
@@ -874,7 +874,7 @@ int device_add(struct device *dev)
 	 * the name, and force the use of dev_name()
 	 */
 	if (dev->init_name) {
-		dev_set_name(dev, dev->init_name);
+		dev_set_name(dev, "%s", dev->init_name);
 		dev->init_name = NULL;
 	}
 
@@ -1271,7 +1271,7 @@ struct device *__root_device_register(co
 	if (!root)
 		return ERR_PTR(err);
 
-	err = dev_set_name(&root->dev, name);
+	err = dev_set_name(&root->dev, "%s", name);
 	if (err) {
 		kfree(root);
 		return ERR_PTR(err);
drivers/base/sys.c +1 -1
Index: linux-work/drivers/base/sys.c
===================================================================
@@ -138,7 +138,7 @@ int sysdev_class_register(struct sysdev_
 	cls->kset.kobj.parent = &system_kset->kobj;
 	cls->kset.kobj.ktype = &ktype_sysdev_class;
 	cls->kset.kobj.kset = system_kset;
-	kobject_set_name(&cls->kset.kobj, cls->name);
+	kobject_set_name(&cls->kset.kobj, "%s", cls->name);
 	return kset_register(&cls->kset);
 }
 
drivers/base/attribute_container.c +1 -1
Index: linux-work/drivers/base/attribute_container.c
===================================================================
@@ -167,7 +167,7 @@ attribute_container_add_device(struct de
 		ic->classdev.parent = get_device(dev);
 		ic->classdev.class = cont->class;
 		cont->class->dev_release = attribute_container_release;
-		dev_set_name(&ic->classdev, dev_name(dev));
+		dev_set_name(&ic->classdev, "%s", dev_name(dev));
 		if (fn)
 			fn(cont, dev, &ic->classdev);
 		else
drivers/base/firmware_class.c +1 -1
Index: linux-work/drivers/base/firmware_class.c
===================================================================
@@ -392,7 +392,7 @@ static int fw_register_device(struct dev
 	fw_priv->timeout.data = (u_long) fw_priv;
 	init_timer(&fw_priv->timeout);
 
-	dev_set_name(f_dev, dev_name(device));
+	dev_set_name(f_dev, "%s", dev_name(device));
 	f_dev->parent = device;
 	f_dev->class = &firmware_class;
 	dev_set_drvdata(f_dev, fw_priv);
drivers/base/platform.c +1 -1
Index: linux-work/drivers/base/platform.c
===================================================================
@@ -244,7 +244,7 @@ int platform_device_add(struct platform_
 	if (pdev->id != -1)
 		dev_set_name(&pdev->dev, "%s.%d", pdev->name,  pdev->id);
 	else
-		dev_set_name(&pdev->dev, pdev->name);
+		dev_set_name(&pdev->dev, "%s", pdev->name);
 
 	for (i = 0; i < pdev->num_resources; i++) {
 		struct resource *p, *r = &pdev->resource[i];
#1 lore raw
Quoted 8 lines · Benjamin Herrenschmidt

gcc is too smart, we get:

drivers/base/core.c: In function ‘device_add’:
drivers/base/core.c:877: warning: format not a string literal and no format arguments drivers/base/core.c: In function ‘__root_device_register’:
drivers/base/core.c:1274: warning: format not a string literal and no format arguments

With 4.3.3 and later. This fixes a bunch of them in drivers/base

These have all been fixed in linux-next for a while, and are already contained in the patchset I sent to Linus for inclusion in his tree yesterday.

But thanks anyway :)

greg k-h

#2 lore raw
Quoted 6 lines · Greg KH

These have all been fixed in linux-next for a while, and are already contained in the patchset I sent to Linus for inclusion in his tree yesterday.

But thanks anyway :)

Argh, oh well ... I should have waited one more day :-)

Cheers,
Ben.