Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1728789 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-09-08 14:30 +0200 |
| Last post | 2017-09-11 15:30 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] [media] DaVinci-VPBE-Display: Adjustments for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-08 14:30 +0200
[PATCH 3/3] [media] DaVinci-VPBE-Display: Adjust 12 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-08 14:40 +0200
Re: [PATCH 3/3] [media] DaVinci-VPBE-Display: Adjust 12 checks for null pointers "Lad, Prabhakar" <prabhakar.csengg@gmail.com> - 2017-09-11 15:30 +0200
[PATCH 1/3] [media] DaVinci-VPBE-Display: Delete an error message for a failed memory allocation in init_vpbe_layer() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-08 14:40 +0200
Re: [PATCH 1/3] [media] DaVinci-VPBE-Display: Delete an error message for a failed memory allocation in init_vpbe_layer() "Lad, Prabhakar" <prabhakar.csengg@gmail.com> - 2017-09-11 15:30 +0200
[PATCH 2/3] [media] DaVinci-VPBE-Display: Improve a size determination in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-08 14:40 +0200
Re: [PATCH 2/3] [media] DaVinci-VPBE-Display: Improve a size determination in two functions "Lad, Prabhakar" <prabhakar.csengg@gmail.com> - 2017-09-11 15:30 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-08 14:30 +0200 |
| Subject | [PATCH 0/3] [media] DaVinci-VPBE-Display: Adjustments for some function implementations |
| Message-ID | <unqA2-6Yv-19@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 8 Sep 2017 14:12:10 +0200 Three update suggestions were taken into account from static source code analysis. Markus Elfring (3): Delete an error message for a failed memory allocation in init_vpbe_layer() Improve a size determination in two functions Adjust 12 checks for null pointers drivers/media/platform/davinci/vpbe_display.c | 37 +++++++++++---------------- 1 file changed, 15 insertions(+), 22 deletions(-) -- 2.14.1
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-08 14:40 +0200 |
| Subject | [PATCH 3/3] [media] DaVinci-VPBE-Display: Adjust 12 checks for null pointers |
| Message-ID | <unqJH-71y-5@gated-at.bofh.it> |
| In reply to | #1728789 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Sep 2017 14:00: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 <elfring@users.sourceforge.net>
---
drivers/media/platform/davinci/vpbe_display.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index afe31900f5de..6aabd21fe69f 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -122,7 +122,7 @@ static irqreturn_t venc_isr(int irq, void *arg)
int fid;
int i;
- if ((NULL == arg) || (NULL == disp_dev->dev[0]))
+ if (!arg || !disp_dev->dev[0])
return IRQ_HANDLED;
if (venc_is_second_field(disp_dev))
@@ -337,10 +337,10 @@ static void vpbe_stop_streaming(struct vb2_queue *vq)
vb2_buffer_done(&layer->cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
} else {
- if (layer->cur_frm != NULL)
+ if (layer->cur_frm)
vb2_buffer_done(&layer->cur_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
- if (layer->next_frm != NULL)
+ if (layer->next_frm)
vb2_buffer_done(&layer->next_frm->vb.vb2_buf,
VB2_BUF_STATE_ERROR);
}
@@ -947,7 +947,7 @@ static int vpbe_display_s_std(struct file *file, void *priv,
if (vb2_is_busy(&layer->buffer_queue))
return -EBUSY;
- if (NULL != vpbe_dev->ops.s_std) {
+ if (vpbe_dev->ops.s_std) {
ret = vpbe_dev->ops.s_std(vpbe_dev, std_id);
if (ret) {
v4l2_err(&vpbe_dev->v4l2_dev,
@@ -1000,8 +1000,7 @@ static int vpbe_display_enum_output(struct file *file, void *priv,
v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_OUTPUT\n");
/* Enumerate outputs */
-
- if (NULL == vpbe_dev->ops.enum_outputs)
+ if (!vpbe_dev->ops.enum_outputs)
return -EINVAL;
ret = vpbe_dev->ops.enum_outputs(vpbe_dev, output);
@@ -1030,7 +1029,7 @@ static int vpbe_display_s_output(struct file *file, void *priv,
if (vb2_is_busy(&layer->buffer_queue))
return -EBUSY;
- if (NULL == vpbe_dev->ops.set_output)
+ if (!vpbe_dev->ops.set_output)
return -EINVAL;
ret = vpbe_dev->ops.set_output(vpbe_dev, i);
@@ -1077,7 +1076,7 @@ vpbe_display_enum_dv_timings(struct file *file, void *priv,
v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_DV_TIMINGS\n");
/* Enumerate outputs */
- if (NULL == vpbe_dev->ops.enum_dv_timings)
+ if (!vpbe_dev->ops.enum_dv_timings)
return -EINVAL;
ret = vpbe_dev->ops.enum_dv_timings(vpbe_dev, timings);
@@ -1292,7 +1291,7 @@ static int vpbe_device_get(struct device *dev, void *data)
if (strcmp("vpbe_controller", pdev->name) == 0)
vpbe_disp->vpbe_dev = platform_get_drvdata(pdev);
- if (strstr(pdev->name, "vpbe-osd") != NULL)
+ if (strstr(pdev->name, "vpbe-osd"))
vpbe_disp->osd_device = platform_get_drvdata(pdev);
return 0;
@@ -1408,7 +1407,7 @@ static int vpbe_display_probe(struct platform_device *pdev)
v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev;
/* Initialize the vpbe display controller */
- if (NULL != disp_dev->vpbe_dev->ops.initialize) {
+ if (disp_dev->vpbe_dev->ops.initialize) {
err = disp_dev->vpbe_dev->ops.initialize(&pdev->dev,
disp_dev->vpbe_dev);
if (err) {
@@ -1476,7 +1475,7 @@ static int vpbe_display_probe(struct platform_device *pdev)
probe_out:
for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) {
/* Unregister video device */
- if (disp_dev->dev[k] != NULL) {
+ if (disp_dev->dev[k]) {
video_unregister_device(&disp_dev->dev[k]->video_dev);
kfree(disp_dev->dev[k]);
}
@@ -1498,7 +1497,7 @@ static int vpbe_display_remove(struct platform_device *pdev)
v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_remove\n");
/* deinitialize the vpbe display controller */
- if (NULL != vpbe_dev->ops.deinitialize)
+ if (vpbe_dev->ops.deinitialize)
vpbe_dev->ops.deinitialize(&pdev->dev, vpbe_dev);
/* un-register device */
for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | "Lad, Prabhakar" <prabhakar.csengg@gmail.com> |
|---|---|
| Date | 2017-09-11 15:30 +0200 |
| Subject | Re: [PATCH 3/3] [media] DaVinci-VPBE-Display: Adjust 12 checks for null pointers |
| Message-ID | <uowWJ-3Qa-5@gated-at.bofh.it> |
| In reply to | #1728791 |
On Fri, Sep 8, 2017 at 1:33 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Fri, 8 Sep 2017 14:00: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 <elfring@users.sourceforge.net> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Cheers, --Prabhakar Lad
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-08 14:40 +0200 |
| Subject | [PATCH 1/3] [media] DaVinci-VPBE-Display: Delete an error message for a failed memory allocation in init_vpbe_layer() |
| Message-ID | <unqJH-71y-15@gated-at.bofh.it> |
| In reply to | #1728789 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 7 Sep 2017 22:37:16 +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 <elfring@users.sourceforge.net>
---
drivers/media/platform/davinci/vpbe_display.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 13d027031ff0..5b6fc550736b 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1313,7 +1313,6 @@ static int init_vpbe_layer(int i, struct vpbe_display *disp_dev,
- if (!disp_dev->dev[i]) {
- printk(KERN_ERR "ran out of memory\n");
+ if (!disp_dev->dev[i])
return -ENOMEM;
- }
+
spin_lock_init(&disp_dev->dev[i]->irqlock);
mutex_init(&disp_dev->dev[i]->opslock);
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | "Lad, Prabhakar" <prabhakar.csengg@gmail.com> |
|---|---|
| Date | 2017-09-11 15:30 +0200 |
| Subject | Re: [PATCH 1/3] [media] DaVinci-VPBE-Display: Delete an error message for a failed memory allocation in init_vpbe_layer() |
| Message-ID | <uowWK-3Qa-19@gated-at.bofh.it> |
| In reply to | #1728793 |
On Fri, Sep 8, 2017 at 1:31 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 7 Sep 2017 22:37:16 +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 <elfring@users.sourceforge.net> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Cheers, --Prabhakar Lad
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-09-08 14:40 +0200 |
| Subject | [PATCH 2/3] [media] DaVinci-VPBE-Display: Improve a size determination in two functions |
| Message-ID | <unqJH-71y-13@gated-at.bofh.it> |
| In reply to | #1728789 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 8 Sep 2017 10:50:32 +0200 Replace the specification of data structures 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 <elfring@users.sourceforge.net> --- drivers/media/platform/davinci/vpbe_display.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 5b6fc550736b..afe31900f5de 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -1305,9 +1305,5 @@ static int init_vpbe_layer(int i, struct vpbe_display *disp_dev, struct video_device *vbd = NULL; /* Allocate memory for four plane display objects */ - - disp_dev->dev[i] = - kzalloc(sizeof(struct vpbe_layer), GFP_KERNEL); - - /* If memory allocation fails, return error */ + disp_dev->dev[i] = kzalloc(sizeof(*disp_dev->dev[i]), GFP_KERNEL); if (!disp_dev->dev[i]) @@ -1396,6 +1392,5 @@ static int vpbe_display_probe(struct platform_device *pdev) printk(KERN_DEBUG "vpbe_display_probe\n"); /* Allocate memory for vpbe_display */ - disp_dev = devm_kzalloc(&pdev->dev, sizeof(struct vpbe_display), - GFP_KERNEL); + disp_dev = devm_kzalloc(&pdev->dev, sizeof(*disp_dev), GFP_KERNEL); if (!disp_dev) -- 2.14.1
[toc] | [prev] | [next] | [standalone]
| From | "Lad, Prabhakar" <prabhakar.csengg@gmail.com> |
|---|---|
| Date | 2017-09-11 15:30 +0200 |
| Subject | Re: [PATCH 2/3] [media] DaVinci-VPBE-Display: Improve a size determination in two functions |
| Message-ID | <uowWJ-3Qa-13@gated-at.bofh.it> |
| In reply to | #1728795 |
On Fri, Sep 8, 2017 at 1:32 PM, SF Markus Elfring <elfring@users.sourceforge.net> wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Fri, 8 Sep 2017 10:50:32 +0200 > > Replace the specification of data structures 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 <elfring@users.sourceforge.net> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Cheers, --Prabhakar Lad
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web