Atmel: Adjustments for seven function implementations
cover Atmel: Adjustments for seven function implementations
From: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 21:44:55 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (6):
Delete an error message for a failed memory allocation in isc_formats_init() Improve a size determination in isc_formats_init()
Adjust three checks for null pointers
Delete an error message for a failed memory allocation in two functions Improve three size determinations
Adjust a null pointer check in three functions
drivers/media/platform/atmel/atmel-isc.c | 12 +++++------- drivers/media/platform/atmel/atmel-isi.c | 20 ++++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/6 atmel-isc: Delete an error message for a failed memory allocation in isc_formats_init()
From: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 20:33:58 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/media/platform/atmel/atmel-isc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/atmel/atmel-isc.c +1 -3
@@ -1510,7 +1510,5 @@ static int isc_formats_init(struct isc_device *isc) -if (!isc->user_formats) { -v4l2_err (&isc->v4l2_dev,"could not allocate memory\n" ); +if (!isc->user_formats)return -ENOMEM ; - } fmt = &isc_formats[0 ];for (i =0 , j =0 ; i <ARRAY_SIZE (isc_formats); i++) {
Signature · 1 line
2.14.1
PATCH 2/6 atmel-isc: Improve a size determination in isc_formats_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 20:50:22 +0200
Replace the specification of a data type 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.
--- drivers/media/platform/atmel/atmel-isc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/atmel/atmel-isc.c +1 -1
@@ -1505,6 +1505,6 @@ static int isc_formats_init(struct isc_device *isc) isc->num_user_formats = num_fmts; isc->user_formats =devm_kcalloc (isc->dev, - num_fmts,sizeof (struct isc_format *), + num_fmts,sizeof (*isc->user_formats),GFP_KERNEL );if (!isc->user_formats)
Signature · 1 line
2.14.1
PATCH 3/6 atmel-isc: Adjust three checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 20:54:20 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
--- drivers/media/platform/atmel/atmel-isc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/atmel/atmel-isc.c +3 -3
@@ -1590,7 +1590,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)spin_lock_init (&isc->dma_queue_lock); sd_entity->config =v4l2_subdev_alloc_pad_config (sd_entity->sd); -if (sd_entity->config =NULL ) +if (!sd_entity->config)return -ENOMEM ; ret =isc_formats_init (isc);
@@ -1714,7 +1714,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) subdev_entity =devm_kzalloc (dev,sizeof (*subdev_entity),GFP_KERNEL ); -if (subdev_entity =NULL ) { +if (!subdev_entity) {of_node_put (rem); ret = -ENOMEM ;break ;
@@ -1722,7 +1722,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) subdev_entity->asd =devm_kzalloc (dev,sizeof (*subdev_entity->asd),GFP_KERNEL ); -if (subdev_entity->asd =NULL ) { +if (!subdev_entity->asd) {of_node_put (rem); ret = -ENOMEM ;break ;
Signature · 1 line
2.14.1
PATCH 4/6 atmel-isi: Delete an error message for a failed memory allocation in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 21:21:25 +0200
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/media/platform/atmel/atmel-isi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/media/platform/atmel/atmel-isi.c +2 -6
@@ -1041,7 +1041,5 @@ static int isi_formats_init(struct atmel_isi *isi) -if (!isi->user_formats) { -dev_err (isi->dev,"could not allocate memory\n" ); +if (!isi->user_formats)return -ENOMEM ; - }memcpy (isi->user_formats, isi_fmts, num_fmts *sizeof (struct isi_format *));
@@ -1179,7 +1177,5 @@ static int atmel_isi_probe(struct platform_device *pdev) -if (!isi) { -dev_err (&pdev->dev,"Can't allocate interface!\n" ); +if (!isi)return -ENOMEM ; - } isi->pclk =devm_clk_get (&pdev->dev,"isi_clk" );if (IS_ERR (isi->pclk))
Signature · 1 line
2.14.1
PATCH 5/6 atmel-isi: Improve three size determinations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 21:27:45 +0200
Replace the specification of data types by pointer dereferences 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/platform/atmel/atmel-isi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/atmel/atmel-isi.c +3 -3
@@ -1036,13 +1036,13 @@ static int isi_formats_init(struct atmel_isi *isi) isi->num_user_formats = num_fmts; isi->user_formats =devm_kcalloc (isi->dev, - num_fmts,sizeof (struct isi_format *), + num_fmts,sizeof (*isi->user_formats),GFP_KERNEL );if (!isi->user_formats)return -ENOMEM ;memcpy (isi->user_formats, isi_fmts, - num_fmts *sizeof (struct isi_format *)); + num_fmts *sizeof (*isi->user_formats)); isi->current_fmt = isi->user_formats[0 ];return 0 ;
@@ -1173,5 +1173,5 @@ static int atmel_isi_probe(struct platform_device *pdev)struct resource *regs;int ret, i; - isi =devm_kzalloc (&pdev->dev,sizeof (struct atmel_isi ),GFP_KERNEL ); + isi =devm_kzalloc (&pdev->dev,sizeof (*isi),GFP_KERNEL );if (!isi)
Signature · 1 line
2.14.1
PATCH 6/6 atmel-isi: Adjust a null pointer check in three functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 21:30:48 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
--- drivers/media/platform/atmel/atmel-isi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/atmel/atmel-isi.c +3 -3
@@ -411,7 +411,7 @@ static void buffer_queue(struct vb2_buffer *vb)spin_lock_irqsave (&isi->irqlock, flags);list_add_tail (&buf->list, &isi->video_buffer_list); -if (isi->active =NULL ) { +if (!isi->active) { isi->active = buf;if (vb2_is_streaming (vb->vb2_queue))start_dma (isi, buf);
@@ -1141,7 +1141,7 @@ static int isi_graph_init(struct atmel_isi *isi)/* Register the subdevices notifier. */ subdevs =devm_kzalloc (isi->dev,sizeof (*subdevs),GFP_KERNEL ); -if (subdevs =NULL ) { +if (!subdevs) {of_node_put (isi->entity.node);return -ENOMEM ; }
@@ -1200,7 +1200,7 @@ static int atmel_isi_probe(struct platform_device *pdev)return ret; isi->vdev =video_device_alloc (); -if (isi->vdev =NULL ) { +if (!isi->vdev) { ret = -ENOMEM ; goto err_vdev_alloc; }
Signature · 1 line
2.14.1
Hi,
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 21:44:55 +0200A few update suggestions were taken into account
from static source code analysis.
Thank you for your patches.
You can add my Acked-by for the patch series.
Quoted 9 lines
Markus Elfring (6):
Delete an error message for a failed memory allocation inisc_formats_init()Improve a size determination inisc_formats_init()
Adjust three checks for null pointers
Delete an error message for a failed memory allocation in two functions Improve three size determinations
Adjust a null pointer check in three functions
Quoted 4 lines
drivers/media/platform/atmel/atmel-isc.c | 12 +++++------- drivers/media/platform/atmel/atmel-isi.c | 20 ++++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-)
Best Regards,
Wenyou Yang
Ludovic Desroches
Acked-byQuoted 7 lines · Wenyou
Hi,
Quoted 3 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 4 Sep 2017 21:44:55 +0200
Quoted 7 lines
Quoted 2 lines
A few update suggestions were taken into account
from static source code analysis.Thank you for your patches.
You can add my Acked-by for the patch series.
Acked-by Wenyou Yang <[email protected]>
Quoted 17 lines
Quoted 10 lines
Markus Elfring (6):
Delete an error message for a failed memory allocation inisc_formats_init()Improve a size determination inisc_formats_init()
Adjust three checks for null pointers
Delete an error message for a failed memory allocation in two functions Improve three size determinations
Adjust a null pointer check in three functionsQuoted 4 lines
drivers/media/platform/atmel/atmel-isc.c | 12 +++++------- drivers/media/platform/atmel/atmel-isi.c | 20 ++++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-)Best Regards,
Wenyou Yang