Skip to contentSkip to conversation

Si2157: Adjustments for two function implementations

PATCH New SF Markus Elfring 1 participant 3 messages Sep 17, 2017

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

cover Si2157: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Sun, 17 Sep 2017 08:48:24 +0200

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

Markus Elfring (2):
Delete an error message for a failed memory allocation Improve a size determination in two functions

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

PATCH 1/2 si2157: Delete an error message for a failed memory allocation in si2157_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 17 Sep 2017 08:20:04 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/tuners/si2157.c | 1 -
 1 file changed, 1 deletion(-)
drivers/media/tuners/si2157.c +0 -1
index e35b1faf0ddc..aefa85718496 100644
@@ -439,6 +439,5 @@ static int si2157_probe(struct i2c_client *client,
 	if (!dev) {
 		ret = -ENOMEM;
-		dev_err(&client->dev, "kzalloc() failed\n");
 		goto err;
 	}
 
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/2 si2157: Improve a size determination in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 17 Sep 2017 08:32:17 +0200

Replace the specification of data structures by variable references as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/media/tuners/si2157.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/tuners/si2157.c +2 -2
index aefa85718496..e3e2027a5027 100644
@@ -457,7 +457,7 @@ static int si2157_probe(struct i2c_client *client,
 	if (ret)
 		goto err_kfree;
 
-	memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
+	memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(si2157_ops));
 	fe->tuner_priv = client;
 
 #ifdef CONFIG_MEDIA_CONTROLLER
@@ -514,7 +514,7 @@ static int si2157_remove(struct i2c_client *client)
 		media_device_unregister_entity(&dev->ent);
 #endif
 
-	memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
+	memset(&fe->ops.tuner_ops, 0, sizeof(fe->ops.tuner_ops));
 	fe->tuner_priv = NULL;
 	kfree(dev);
 
Signature · 1 line
2.14.1