Skip to contentSkip to conversation

Mantis: Adjustments for three function implementations

PATCH New SF Markus Elfring 1 participant 8 messages Sep 2, 2017

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

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
#1 lore raw

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
index 68b5800030b7..cc1bb04d8cb4 100644
@@ -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
#2 lore raw

PATCH 2/7 Hopper: Improve a size determination in hopper_pci_probe()

In reply to SF Markus Elfring

From: 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
index cc1bb04d8cb4..fe7b40c306f7 100644
@@ -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
#3 lore raw

PATCH 3/7 Hopper: Adjust a null pointer check in two functions

In reply to SF Markus Elfring

From: 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
index fe7b40c306f7..88e5b2a97005 100644
@@ -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
#4 lore raw

PATCH 4/7 Hopper: Delete an unnecessary variable initialisation in hopper_pci_probe()

In reply to SF Markus Elfring

From: 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
index 88e5b2a97005..3826be19c156 100644
@@ -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
#5 lore raw

PATCH 5/7 Mantis: Delete an error message for a failed memory allocation in mantis_pci_probe()

In reply to SF Markus Elfring

From: 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
index cdefffc16d9e..56a01f6f84c7 100644
@@ -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
#6 lore raw

PATCH 6/7 Mantis: Improve a size determination in mantis_pci_probe()

In reply to SF Markus Elfring

From: 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
index 56a01f6f84c7..6182ae44dd23 100644
@@ -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
#7 lore raw

PATCH 7/7 Mantis: Delete an unnecessary variable initialisation in mantis_pci_probe()

In reply to SF Markus Elfring

From: 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
index 6182ae44dd23..33dd99da0ed8 100644
@@ -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