Skip to contentSkip to conversation

MR800: Adjustments for usb_amradio_probe()

PATCH New SF Markus Elfring 1 participant 4 messages Sep 16, 2017

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

cover MR800: Adjustments for usb_amradio_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 12:35:43 +0200

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

Markus Elfring (3):
Delete two error messages for a failed memory allocation Improve a size determination
Delete an unnecessary variable initialisation

 drivers/media/radio/radio-mr800.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/3 mr800: Delete two error messages for a failed memory allocation in usb_amradio_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 11:23:53 +0200

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/media/radio/radio-mr800.c | 2 --
 1 file changed, 2 deletions(-)
drivers/media/radio/radio-mr800.c +0 -2
index c9f59129af79..63a9b92ab495 100644
@@ -518,5 +518,4 @@ static int usb_amradio_probe(struct usb_interface *intf,
 	if (!radio) {
-		dev_err(&intf->dev, "kmalloc for amradio_device failed\n");
 		retval = -ENOMEM;
 		goto err;
 	}
@@ -526,5 +525,4 @@ static int usb_amradio_probe(struct usb_interface *intf,
 	if (!radio->buffer) {
-		dev_err(&intf->dev, "kmalloc for radio->buffer failed\n");
 		retval = -ENOMEM;
 		goto err_nobuf;
 	}
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/3 mr800: Improve a size determination in usb_amradio_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 11:34:11 +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/radio/radio-mr800.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/radio/radio-mr800.c +1 -2
index 63a9b92ab495..7c4554ce1cf0 100644
@@ -515,4 +515,3 @@ static int usb_amradio_probe(struct usb_interface *intf,
 
-	radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL);
-
+	radio = kzalloc(sizeof(*radio), GFP_KERNEL);
 	if (!radio) {
Signature · 1 line
2.14.1
#3 lore raw

PATCH 3/3 mr800: Delete an unnecessary variable initialisation in usb_amradio_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 11:39:50 +0200

The variable "retval" will eventually be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/media/radio/radio-mr800.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/radio-mr800.c +1 -1
index 7c4554ce1cf0..a1f4dc9be284 100644
@@ -511,5 +511,5 @@ static int usb_amradio_probe(struct usb_interface *intf,
 				const struct usb_device_id *id)
 {
 	struct amradio_device *radio;
-	int retval = 0;
+	int retval;
 
Signature · 1 line
2.14.1