Mantis: Adjustments for three function implementations
Subsystems (2)
cover Mantis: Adjustments for three function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 22:18:22 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (7):
Delete an error message for a failed memory allocation in hopper_pci_probe() Improve a size determination in hopper_pci_probe()
Adjust a null pointer check in two functions
Delete an unnecessary variable initialisation in hopper_pci_probe() Delete an error message for a failed memory allocation in mantis_pci_probe() Improve a size determination in mantis_pci_probe()
Delete an unnecessary variable initialisation in mantis_pci_probe()
drivers/media/pci/mantis/hopper_cards.c | 9 ++++----- drivers/media/pci/mantis/mantis_cards.c | 8 +++----- 2 files changed, 7 insertions(+), 10 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/7 Hopper: Delete an error message for a failed memory allocation in hopper_pci_probe()
From: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 21:19:05 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/media/pci/mantis/hopper_cards.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/pci/mantis/hopper_cards.c +0 -1
@@ -168,4 +168,3 @@ static int hopper_pci_probe(struct pci_dev *pdev, -printk (KERN_ERR "%s ERROR: Out of memory\n" , __func__); err = -ENOMEM ; goto fail0; }
Signature · 1 line
2.14.1
PATCH 2/7 Hopper: Improve a size determination in hopper_pci_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 21:21:22 +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/media/pci/mantis/hopper_cards.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/mantis/hopper_cards.c +1 -1
@@ -163,7 +163,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,struct mantis_hwconfig *config;int err =0 ; - mantis =kzalloc (sizeof (struct mantis_pci ),GFP_KERNEL ); + mantis =kzalloc (sizeof (*mantis),GFP_KERNEL );if (mantis =NULL ) { err = -ENOMEM ; goto fail0;
Signature · 1 line
2.14.1
PATCH 3/7 Hopper: Adjust a null pointer check in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 21:25:50 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
--- drivers/media/pci/mantis/hopper_cards.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/mantis/hopper_cards.c +2 -2
@@ -72,7 +72,7 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)struct mantis_ca *ca; mantis = (struct mantis_pci *) dev_id; -if (unlikely (mantis =NULL )) { +if (unlikely (!mantis)) {dprintk (MANTIS_ERROR ,1 ,"Mantis = NULL" );return IRQ_NONE ; }
@@ -164,7 +164,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,int err =0 ; mantis =kzalloc (sizeof (*mantis),GFP_KERNEL ); -if (mantis =NULL ) { +if (!mantis) { err = -ENOMEM ; goto fail0; }
Signature · 1 line
2.14.1
PATCH 4/7 Hopper: Delete an unnecessary variable initialisation in hopper_pci_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 21:50:55 +0200
The variable "err" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/media/pci/mantis/hopper_cards.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/mantis/hopper_cards.c +1 -1
@@ -161,6 +161,6 @@ static int hopper_pci_probe(struct pci_dev *pdev,struct mantis_pci_drvdata *drvdata;struct mantis_pci *mantis;struct mantis_hwconfig *config; -int err =0 ; +int err; mantis =kzalloc (sizeof (*mantis),GFP_KERNEL );
Signature · 1 line
2.14.1
PATCH 5/7 Mantis: Delete an error message for a failed memory allocation in mantis_pci_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 21:55:05 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/media/pci/mantis/mantis_cards.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/pci/mantis/mantis_cards.c +1 -3
@@ -177,7 +177,5 @@ static int mantis_pci_probe(struct pci_dev *pdev, -if (mantis =NULL ) { -printk (KERN_ERR "%s ERROR: Out of memory\n" , __func__); +if (!mantis)return -ENOMEM ; - } drvdata = (void *)pci_id->driver_data; mantis->num = devs;
Signature · 1 line
2.14.1
PATCH 6/7 Mantis: Improve a size determination in mantis_pci_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 21:56:07 +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/media/pci/mantis/mantis_cards.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/mantis/mantis_cards.c +1 -1
@@ -173,5 +173,5 @@ static int mantis_pci_probe(struct pci_dev *pdev,struct mantis_hwconfig *config;int err =0 ; - mantis =kzalloc (sizeof (struct mantis_pci ),GFP_KERNEL ); + mantis =kzalloc (sizeof (*mantis),GFP_KERNEL );if (!mantis)
Signature · 1 line
2.14.1
PATCH 7/7 Mantis: Delete an unnecessary variable initialisation in mantis_pci_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 2 Sep 2017 22:05:22 +0200
The variable "err" will eventually be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/media/pci/mantis/mantis_cards.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/mantis/mantis_cards.c +1 -1
@@ -171,6 +171,6 @@ static int mantis_pci_probe(struct pci_dev *pdev,struct mantis_pci_drvdata *drvdata;struct mantis_pci *mantis;struct mantis_hwconfig *config; -int err =0 ; +int err; mantis =kzalloc (sizeof (*mantis),GFP_KERNEL );
Signature · 1 line
2.14.1