Skip to contentSkip to conversation

PNP: Adjustments for four function implementations

PATCH In review SF Markus Elfring 2 participants 9 messages May 15, 2017 – Dec 18, 2017

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

cover PNP: Adjustments for four function implementations

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 21:03:21 +0200

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

Markus Elfring (6):
Delete an error message for a failed memory allocation in pnp_alloc() Improve a size determination in pnp_alloc_dev()
Improve a size determination in pnp_clone_dependent_set()
Delete an error message for a failed memory allocation in pnp_clone_dependent_set() Improve a size determination in quirk_awe32_add_ports()
Delete an error message for a failed memory allocation in quirk_awe32_add_ports()

 drivers/pnp/core.c   |  6 ++----
 drivers/pnp/quirks.c | 15 ++++-----------
 2 files changed, 6 insertions(+), 15 deletions(-)
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/6 PNP: Delete an error message for a failed memory allocation in pnp_alloc()

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 19:35:29 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/pnp/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pnp/core.c +1 -3
index b54620e53830..27945a2d9c4e 100644
@@ -35,10 +35,8 @@ void *pnp_alloc(long size)
 	void *result;
 
 	result = kzalloc(size, GFP_KERNEL);
-	if (!result) {
-		printk(KERN_ERR "pnp: Out of Memory\n");
+	if (!result)
 		return NULL;
-	}
 	return result;
 }
 
Signature · 1 line
2.13.0
#2 lore raw

PATCH 2/6 PNP: Improve a size determination in pnp_alloc_dev()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 19:45:23 +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.

---
 drivers/pnp/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pnp/core.c +1 -1
index 27945a2d9c4e..6ccec10aed11 100644
@@ -141,7 +141,7 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
 	struct pnp_dev *dev;
 	struct pnp_id *dev_id;
 
-	dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return NULL;
 
Signature · 1 line
2.13.0
#3 lore raw

PATCH 3/6 PNP: Improve a size determination in pnp_clone_dependent_set()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 19:52:26 +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.

---
 drivers/pnp/quirks.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pnp/quirks.c +1 -2
index d28e3ab9479c..215a50723243 100644
@@ -155,6 +155,5 @@ static struct pnp_option *pnp_clone_dependent_set(struct pnp_dev *dev,
 	list_for_each_entry(option, &dev->options, list) {
 		if (pnp_option_is_dependent(option) &&
 		    pnp_option_set(option) = set) {
-			new_option = kmalloc(sizeof(struct pnp_option),
-					     GFP_KERNEL);
+			new_option = kmalloc(sizeof(*new_option), GFP_KERNEL);
 			if (!new_option) {
Signature · 1 line
2.13.0
#4 lore raw

PATCH 4/6 PNP: Delete an error message for a failed memory allocation in pnp_clone_dependent_set()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 20:00:38 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/pnp/quirks.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pnp/quirks.c +1 -4
index 215a50723243..34e2d4563bbd 100644
@@ -159,8 +159,5 @@ static struct pnp_option *pnp_clone_dependent_set(struct pnp_dev *dev,
-			if (!new_option) {
-				dev_err(&dev->dev, "couldn't clone dependent "
-					"set %d\n", set);
+			if (!new_option)
 				return NULL;
-			}
 
 			*new_option = *option;
 			new_option->flags = flags;
Signature · 1 line
2.13.0
#5 lore raw

PATCH 5/6 PNP: Improve a size determination in quirk_awe32_add_ports()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 20:32:12 +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.

---
 drivers/pnp/quirks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pnp/quirks.c +1 -1
index 34e2d4563bbd..f9be5f3fb7ea 100644
@@ -29,5 +29,5 @@ static void quirk_awe32_add_ports(struct pnp_dev *dev,
 {
 	struct pnp_option *new_option;
 
-	new_option = kmalloc(sizeof(struct pnp_option), GFP_KERNEL);
+	new_option = kmalloc(sizeof(*new_option), GFP_KERNEL);
 	if (!new_option) {
Signature · 1 line
2.13.0
#6 lore raw

PATCH 6/6 PNP: Delete an error message for a failed memory allocation in quirk_awe32_add_ports()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 20:36:35 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/pnp/quirks.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pnp/quirks.c +1 -4
index f9be5f3fb7ea..ae7fbf105e0a 100644
@@ -33,8 +33,5 @@ static void quirk_awe32_add_ports(struct pnp_dev *dev,
-	if (!new_option) {
-		dev_err(&dev->dev, "couldn't add ioport region to option set "
-			"%d\n", pnp_option_set(option));
+	if (!new_option)
 		return;
-	}
 
 	*new_option = *option;
 	new_option->u.port.min += offset;
Signature · 1 line
2.13.0
#7 lore raw
In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 15 May 2017 21:03:21 +0200

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

You need to fold these 6 in to two:
PNP: Improve a size determination
PNP: Delete an error message for a failed memory allocation

And effectively after I'm not sure the first one even needed for now.

Quoted 16 lines

Markus Elfring (6):
Delete an error message for a failed memory allocation in pnp_alloc() Improve a size determination in pnp_alloc_dev()
Improve a size determination in pnp_clone_dependent_set()
Delete an error message for a failed memory allocation in pnp_clone_dependent_set() Improve a size determination in quirk_awe32_add_ports()
Delete an error message for a failed memory allocation in quirk_awe32_add_ports()

 drivers/pnp/core.c   |  6 ++----
 drivers/pnp/quirks.c | 15 ++++-----------
 2 files changed, 6 insertions(+), 15 deletions(-)

--
2.13.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
In reply to SF Markus Elfring
Quoted 13 lines

Date: Mon, 15 May 2017 21:03:21 +0200

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

Markus Elfring (6):
Delete an error message for a failed memory allocation in pnp_alloc() Improve a size determination in pnp_alloc_dev()
Improve a size determination in pnp_clone_dependent_set()
Delete an error message for a failed memory allocation in pnp_clone_dependent_set() Improve a size determination in quirk_awe32_add_ports()
Delete an error message for a failed memory allocation in quirk_awe32_add_ports()

Quoted 3 lines
 drivers/pnp/core.c   |  6 ++----
 drivers/pnp/quirks.c | 15 ++++-----------
 2 files changed, 6 insertions(+), 15 deletions(-)

How are the chances that such change possibilities will be integrated in this software module?

Regards,
Markus