misc-IBM ASM SP: Adjustments for ibmasm_init_one()
Subsystems (2)
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
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
@@ -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
PATCH 2/3 misc/ibmasm: Improve a size determination in ibmasm_init_one()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/3 misc/ibmasm: Adjust two function calls together with a variable assignment
In reply to SF Markus ElfringFrom: 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
@@ -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