Skip to contentSkip to conversation

si470x: Adjustments for si470x_usb_driver_probe()

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

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

cover si470x: Adjustments for si470x_usb_driver_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 15:16:17 +0200

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
Delete an unnecessary variable initialisation

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

PATCH 1/3 si470x: Delete an error message for a failed memory allocation in si470x_usb_driver_probe()

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

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/media/radio/si470x/radio-si470x-usb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-usb.c +0 -1
index c311f9951d80..af295530b20f 100644
@@ -618,5 +618,4 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
 	if (!radio->int_in_buffer) {
-		dev_info(&intf->dev, "could not allocate int_in_buffer");
 		retval = -ENOMEM;
 		goto err_usbbuf;
 	}
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/3 si470x: Improve a size determination in si470x_usb_driver_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 14:58:06 +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/si470x/radio-si470x-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-usb.c +1 -1
index af295530b20f..6fc6e8235f20 100644
@@ -584,5 +584,5 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
 	/* private data allocation and initialization */
-	radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);
+	radio = kzalloc(sizeof(*radio), GFP_KERNEL);
 	if (!radio) {
 		retval = -ENOMEM;
 		goto err_initial;
Signature · 1 line
2.14.1
#3 lore raw

PATCH 3/3 si470x: Delete an unnecessary variable initialisation in si470x_usb_driver_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 16 Sep 2017 15:08:39 +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/si470x/radio-si470x-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-usb.c +1 -1
index 6fc6e8235f20..ae30e3da9d13 100644
@@ -578,6 +578,6 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
 	struct si470x_device *radio;
 	struct usb_host_interface *iface_desc;
 	struct usb_endpoint_descriptor *endpoint;
-	int i, int_end_size, retval = 0;
+	int i, int_end_size, retval;
 	unsigned char version_warning = 0;
 
Signature · 1 line
2.14.1