Skip to contentSkip to conversation

misc-IBM ASM SP: Adjustments for ibmasm_init_one()

PATCH New SF Markus Elfring 1 participant 4 messages Jan 8, 2018

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

cover misc-IBM ASM SP: Adjustments for ibmasm_init_one()

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jan 2018 14:01:24 +0100

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

Markus Elfring (3):
Delete an error message for a failed memory allocation Improve a size determination
Adjust two function calls together with a variable assignment

 drivers/misc/ibmasm/module.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/3 misc/ibmasm: Delete an error message for a failed memory allocation in ibmasm_init_one()

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jan 2018 13:34:55 +0100

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

This issue was detected by using the Coccinelle software.

---
 drivers/misc/ibmasm/module.c | 1 -
 1 file changed, 1 deletion(-)
drivers/misc/ibmasm/module.c +0 -1
index e914b8c80943..d22b3c428ca9 100644
@@ -80,7 +80,6 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	sp = kzalloc(sizeof(struct service_processor), GFP_KERNEL);
 	if (sp = NULL) {
-		dev_err(&pdev->dev, "Failed to allocate memory\n");
 		result = -ENOMEM;
 		goto error_kmalloc;
 	}
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/3 misc/ibmasm: Improve a size determination in ibmasm_init_one()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jan 2018 13:43:20 +0100

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/misc/ibmasm/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/ibmasm/module.c +1 -1
index d22b3c428ca9..894397b1ee51 100644
@@ -78,7 +78,7 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	/* vnc client won't work without bus-mastering */
 	pci_set_master(pdev);
 
-	sp = kzalloc(sizeof(struct service_processor), GFP_KERNEL);
+	sp = kzalloc(sizeof(*sp), GFP_KERNEL);
 	if (sp = NULL) {
 		result = -ENOMEM;
 		goto error_kmalloc;
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 misc/ibmasm: Adjust two function calls together with a variable assignment

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 8 Jan 2018 13:53:25 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code places.

---
 drivers/misc/ibmasm/module.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/misc/ibmasm/module.c +5 -3
index 894397b1ee51..f4742044e0d1 100644
@@ -64,14 +64,16 @@ MODULE_PARM_DESC(ibmasm_debug, " Set debug mode on or off");
 
 static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-	int result;
 	struct service_processor *sp;
+	int result = pci_enable_device(pdev);
 
-	if ((result = pci_enable_device(pdev))) {
+	if (result) {
 		dev_err(&pdev->dev, "Failed to enable PCI device\n");
 		return result;
 	}
-	if ((result = pci_request_regions(pdev, DRIVER_NAME))) {
+
+	result = pci_request_regions(pdev, DRIVER_NAME);
+	if (result) {
 		dev_err(&pdev->dev, "Failed to allocate PCI resources\n");
 		goto error_resources;
 	}
Signature · 1 line
2.15.1