TDA18212HN: Adjustments for two function implementations
Subsystems (3)
cover TDA18212HN: Adjustments for two function implementations
From: Markus Elfring <[email protected]>
Date: Sun, 17 Sep 2017 10:03:45 +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 three size determinations
drivers/media/tuners/tda18212.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/2 tda18212: Delete an error message for a failed memory allocation in tda18212_probe()
From: Markus Elfring <[email protected]>
Date: Sun, 17 Sep 2017 09:33:58 +0200
* Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
* Add a jump target so that the function "kfree" will be always called with a non-null pointer.
--- drivers/media/tuners/tda18212.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/tuners/tda18212.c +3 -3
@@ -204,6 +204,5 @@ static int tda18212_probe(struct i2c_client *client,if (dev =NULL ) { ret = -ENOMEM ; -dev_err (&client->dev,"kzalloc() failed\n" ); - goto err; + goto report_failure; }
@@ -250,8 +249,9 @@ static int tda18212_probe(struct i2c_client *client,return 0 ; err: -dev_dbg (&client->dev,"failed=%d\n" , ret);kfree (dev); +report_failure: +dev_dbg (&client->dev,"failed=%d\n" , ret);return ret; }
Signature · 1 line
2.14.1
PATCH 2/2 tda18212: Improve three size determinations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Sep 2017 09:42: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/tda18212.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/tuners/tda18212.c +3 -4
@@ -207,6 +207,6 @@ static int tda18212_probe(struct i2c_client *client, } -memcpy (&dev->cfg, cfg,sizeof (struct tda18212_config )); +memcpy (&dev->cfg, cfg,sizeof (*cfg)); dev->client = client; dev->regmap =devm_regmap_init_i2c (client, ®map_config);if (IS_ERR (dev->regmap)) {
@@ -244,7 +244,7 @@ static int tda18212_probe(struct i2c_client *client, fe->tuner_priv = dev;memcpy (&fe->ops.tuner_ops, &tda18212_tuner_ops, -sizeof (struct dvb_tuner_ops )); +sizeof (fe->ops.tuner_ops));i2c_set_clientdata (client, dev);return 0 ;
@@ -261,8 +261,7 @@ static int tda18212_remove(struct i2c_client *client)struct dvb_frontend *fe = dev->cfg.fe;dev_dbg (&client->dev,"\n" ); - -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