Skip to contentSkip to conversation

atm: Adjustments for adummy_init()

PATCH New SF Markus Elfring 1 participant 3 messages Oct 1, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover atm: Adjustments for adummy_init()

From: Markus Elfring <[email protected]>
Date: Sun, 1 Oct 2017 21:43:21 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation Improve a size determination

 drivers/atm/adummy.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Signature · 1 line
2.14.2
#1 lore raw

PATCH 1/2 atm: Delete an error message for a failed memory allocation in adummy_init()

From: Markus Elfring <[email protected]>
Date: Sun, 1 Oct 2017 21:31:32 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/atm/adummy.c | 1 -
 1 file changed, 1 deletion(-)
drivers/atm/adummy.c +0 -1
index 8d98130ecd40..94b73ddfb731 100644
@@ -150,7 +150,6 @@ static int __init adummy_init(void)
 	adummy_dev = kzalloc(sizeof(struct adummy_dev),
 						   GFP_KERNEL);
 	if (!adummy_dev) {
-		printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
 		err = -ENOMEM;
 		goto out;
 	}
Signature · 1 line
2.14.2
#2 lore raw

PATCH 2/2 atm: Improve a size determination in adummy_init()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 1 Oct 2017 21:35:18 +0200

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/atm/adummy.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/atm/adummy.c +1 -3
index 94b73ddfb731..1ef2d8ee8d67 100644
@@ -146,9 +146,7 @@ static int __init adummy_init(void)
 	int err = 0;
 
 	printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
-
-	adummy_dev = kzalloc(sizeof(struct adummy_dev),
-						   GFP_KERNEL);
+	adummy_dev = kzalloc(sizeof(*adummy_dev), GFP_KERNEL);
 	if (!adummy_dev) {
 		err = -ENOMEM;
 		goto out;
Signature · 1 line
2.14.2