2017-09-04 20:04:21

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/6] [media] 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(-)

--
2.14.1


2017-09-04 20:06:15

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/6] [media] 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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/atmel/atmel-isc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index d4df3d4ccd85..f1e635edef72 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -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++) {
--
2.14.1

2017-09-04 20:08:12

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/6] [media] atmel-isc: Improve a size determination in isc_formats_init()

From: 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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/atmel/atmel-isc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index f1e635edef72..f16bab0105c2 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -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)
--
2.14.1

2017-09-04 20:08:57

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 3/6] [media] atmel-isc: Adjust three checks for null pointers

From: 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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/atmel/atmel-isc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index f16bab0105c2..b6048cedb6cc 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -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;
--
2.14.1

2017-09-04 20:10:11

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 4/6] [media] atmel-isi: Delete an error message for a failed memory allocation in two functions

From: 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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/atmel/atmel-isi.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index 891fa2505efa..154e9c39b64f 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -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))
--
2.14.1

2017-09-04 20:11:53

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 5/6] [media] atmel-isi: Improve three size determinations

From: 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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/atmel/atmel-isi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index 154e9c39b64f..ac40defce1e7 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -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)
--
2.14.1

2017-09-04 20:12:57

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 6/6] [media] atmel-isi: Adjust a null pointer check in three functions

From: 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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/atmel/atmel-isi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index ac40defce1e7..f2e13dfb19a1 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -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;
}
--
2.14.1

2017-09-06 00:58:51

by Wenyou Yang

[permalink] [raw]
Subject: Re: [PATCH 0/6] [media] Atmel: Adjustments for seven function implementations

Hi,


On 2017/9/5 4:04, SF Markus Elfring wrote:
> 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.
Thank you for your patches.

You can add my Acked-by for the patch series.

Acked-by: Wenyou Yang <[email protected]>

>
> 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(-)
>

Best Regards,
Wenyou Yang

2017-09-06 06:01:01

by Ludovic Desroches

[permalink] [raw]
Subject: Re: [PATCH 0/6] [media] Atmel: Adjustments for seven function implementations

On Wed, Sep 06, 2017 at 08:58:26AM +0800, Yang, Wenyou wrote:
> Hi,
>
>
> On 2017/9/5 4:04, SF Markus Elfring wrote:
> > 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.
> Thank you for your patches.
>
> You can add my Acked-by for the patch series.
>
> Acked-by: Wenyou Yang <[email protected]>

Acked-by: Ludovic Desroches <[email protected]>

>
> >
> > 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(-)
> >
>
> Best Regards,
> Wenyou Yang