mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] [media] IT913X: Adjustments for two function implementations
@ 2017-09-16 18:30 SF Markus Elfring
  2017-09-16 18:31 ` [PATCH 1/2] [media] it913x: Delete two error messages for a failed memory allocation in it913x_probe() SF Markus Elfring
  2017-09-16 18:32 ` [PATCH 2/2] [media] it913x: Improve three size determinations SF Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-09-16 18:30 UTC (permalink / raw)
  To: linux-media, Antti Palosaari, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 16 Sep 2017 20:12:34 +0200

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

Markus Elfring (2):
  Delete two error messages for a failed memory allocation
  Improve three size determinations

 drivers/media/tuners/it913x.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] [media] it913x: Delete two error messages for a failed memory allocation in it913x_probe()
  2017-09-16 18:30 [PATCH 0/2] [media] IT913X: Adjustments for two function implementations SF Markus Elfring
@ 2017-09-16 18:31 ` SF Markus Elfring
  2017-09-16 18:32 ` [PATCH 2/2] [media] it913x: Improve three size determinations SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-09-16 18:31 UTC (permalink / raw)
  To: linux-media, Antti Palosaari, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 16 Sep 2017 19:40:47 +0200

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

  This issue was detected by using the Coccinelle software.

* Delete the label "err" and the variable "ret" which became unnecessary
  with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/it913x.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c
index 27e5bc1c3cb5..6af9507823fa 100644
--- a/drivers/media/tuners/it913x.c
+++ b/drivers/media/tuners/it913x.c
@@ -392,14 +392,10 @@ static int it913x_probe(struct platform_device *pdev)
 	struct it913x_dev *dev;
 	const struct platform_device_id *id = platform_get_device_id(pdev);
-	int ret;
 	char *chip_ver_str;
 
 	dev = kzalloc(sizeof(struct it913x_dev), GFP_KERNEL);
-	if (dev == NULL) {
-		ret = -ENOMEM;
-		dev_err(&pdev->dev, "kzalloc() failed\n");
-		goto err;
-	}
+	if (!dev)
+		return -ENOMEM;
 
 	dev->pdev = pdev;
 	dev->regmap = pdata->regmap;
@@ -423,9 +419,6 @@ static int it913x_probe(struct platform_device *pdev)
 		 chip_ver_str);
 	dev_dbg(&pdev->dev, "chip_ver %u, role %u\n", dev->chip_ver, dev->role);
 	return 0;
-err:
-	dev_dbg(&pdev->dev, "failed %d\n", ret);
-	return ret;
 }
 
 static int it913x_remove(struct platform_device *pdev)
-- 
2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] [media] it913x: Improve three size determinations
  2017-09-16 18:30 [PATCH 0/2] [media] IT913X: Adjustments for two function implementations SF Markus Elfring
  2017-09-16 18:31 ` [PATCH 1/2] [media] it913x: Delete two error messages for a failed memory allocation in it913x_probe() SF Markus Elfring
@ 2017-09-16 18:32 ` SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-09-16 18:32 UTC (permalink / raw)
  To: linux-media, Antti Palosaari, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 16 Sep 2017 20:06:01 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/it913x.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c
index 6af9507823fa..149f36d5e503 100644
--- a/drivers/media/tuners/it913x.c
+++ b/drivers/media/tuners/it913x.c
@@ -393,5 +393,5 @@ static int it913x_probe(struct platform_device *pdev)
 	const struct platform_device_id *id = platform_get_device_id(pdev);
 	char *chip_ver_str;
 
-	dev = kzalloc(sizeof(struct it913x_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
@@ -404,8 +404,7 @@ static int it913x_probe(struct platform_device *pdev)
 	dev->role = pdata->role;
 
 	fe->tuner_priv = dev;
-	memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops,
-			sizeof(struct dvb_tuner_ops));
+	memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops, sizeof(it913x_tuner_ops));
 	platform_set_drvdata(pdev, dev);
 
 	if (dev->chip_ver == 1)
@@ -427,8 +426,7 @@ static int it913x_remove(struct platform_device *pdev)
 	struct dvb_frontend *fe = dev->fe;
 
 	dev_dbg(&pdev->dev, "\n");
-
-	memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
+	memset(&fe->ops.tuner_ops, 0, sizeof(it913x_tuner_ops));
 	fe->tuner_priv = NULL;
 	kfree(dev);
 
-- 
2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-16 18:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-16 18:30 [PATCH 0/2] [media] IT913X: Adjustments for two function implementations SF Markus Elfring
2017-09-16 18:31 ` [PATCH 1/2] [media] it913x: Delete two error messages for a failed memory allocation in it913x_probe() SF Markus Elfring
2017-09-16 18:32 ` [PATCH 2/2] [media] it913x: Improve three size determinations SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome