Skip to contentSkip to conversation

ACPI: use kstrdup()

PATCH In review Thomas Meyer 2 participants 2 messages Aug 6, 2011 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: use kstrdup()

From: Thomas Meyer <[email protected]>

Use kstrdup rather than duplicating its implementation

The semantic patch that makes this output is available in scripts/coccinelle/api/kstrdup.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

---

drivers/acpi/scan.c 2011-08-01 21:02:46.489387939 +0200 renamed from drivers/acpi/scan.c 2011-05-04 19:24:51.386504770 +0200 +1 -2
diff -u -p a/drivers/acpi/scan.c b/drivers/acpi/scan.c
@@ -1062,13 +1062,12 @@ static void acpi_add_id(struct acpi_devi
 	if (!id)
 		return;
 
-	id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL);
+	id->id = kstrdup(dev_id, GFP_KERNEL);
 	if (!id->id) {
 		kfree(id);
 		return;
 	}
 
-	strcpy(id->id, dev_id);
 	list_add_tail(&id->list, &device->pnp.ids);
 }
 
reviewer
#1 lore raw

applied to acpi-test for 3.2

thanks,
Len Brown, Intel Open Source Technology Center