2018-01-08 13:07:18

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/3] 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(-)

--
2.15.1


2018-01-08 13:08:39

by SF Markus Elfring

[permalink] [raw]
Subject: [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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/misc/ibmasm/module.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index e914b8c80943..d22b3c428ca9 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -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;
}
--
2.15.1

2018-01-08 13:09:40

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/3] misc/ibmasm: Improve a size determination in ibmasm_init_one()

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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/misc/ibmasm/module.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index d22b3c428ca9..894397b1ee51 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -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;
--
2.15.1

2018-01-08 13:10:46

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 3/3] misc/ibmasm: Adjust two function calls together with a variable assignment

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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/misc/ibmasm/module.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index 894397b1ee51..f4742044e0d1 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -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;
}
--
2.15.1