Skip to contentSkip to conversation

HID: hid-lg4ff: Casting (void *) value returned by kmalloc is useless

PATCH Applied Thomas Meyer 3 participants 3 messages Nov 8, 2011 – Nov 11, 2011 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: hid-lg4ff: Casting (void *) value returned by kmalloc is useless

From: Thomas Meyer <[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

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

---

drivers/hid/hid-lg4ff.c 2011-11-08 09:03:29.394045138 +0100 renamed from drivers/hid/hid-lg4ff.c 2011-11-07 19:37:44.816570939 +0100 +1 -1
diff -u -p a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
@@ -430,7 +430,7 @@ int lg4ff_init(struct hid_device *hid)
 	}
 
 	/* Add the device to device_list */
-	entry = (struct lg4ff_device_entry *)kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL);
+	entry = kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL);
 	if (!entry) {
 		hid_err(hid, "Cannot add device, insufficient memory.\n");
 		return -ENOMEM;
#1 lore raw

No objection from me if this is the proper way to do things. Simon.

Quoted 34 lines

From: Thomas Meyer <[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

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

---

diff -u -p a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c

drivers/hid/hid-lg4ff.c 2011-11-08 09:03:29.394045138 +0100 renamed from drivers/hid/hid-lg4ff.c 2011-11-07 19:37:44.816570939 +0100 +1 -1
@@ -430,7 +430,7 @@ int lg4ff_init(struct hid_device *hid)
 	}
 
 	/* Add the device to device_list */
-	entry = (struct lg4ff_device_entry *)kzalloc(sizeof(struct
 lg4ff_device_entry), GFP_KERNEL);
+	entry = kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL);
 	if (!entry) {
 		hid_err(hid, "Cannot add device, insufficient memory.\n");

return -ENOMEM;

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#2 lore raw
In reply to Thomas Meyer
Quoted 18 lines · Thomas Meyer

From: Thomas Meyer <[email protected]>

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci.

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

---

diff -u -p a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c

drivers/hid/hid-lg4ff.c 2011-11-08 09:03:29.394045138 +0100 int lg4ff_init(struct hid_device *hid) · line 436

Quoted 8 lines
drivers/hid/hid-lg4ff.c 2011-11-08 09:03:29.394045138 +0100 renamed from drivers/hid/hid-lg4ff.c 2011-11-07 19:37:44.816570939 +0100 +1 -1
@@ -430,7 +430,7 @@ int lg4ff_init(struct hid_device *hid)
 	}
 
 	/* Add the device to device_list */
-	entry = (struct lg4ff_device_entry *)kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL);
+	entry = kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL);
 	if (!entry) {
 		hid_err(hid, "Cannot add device, insufficient memory.\n");
 		return -ENOMEM;

Applied, thanks Thomas.

Signature · 2 lines
Jiri Kosina
SUSE Labs