Re: [PATCH] omap3isp: ispqueue: Fix uninitialized variable compiler warnings

2013-01-07 Thread Laurent Pinchart
Hi Sakari,

On Saturday 05 January 2013 00:51:36 Sakari Ailus wrote:
> On Mon, Dec 17, 2012 at 09:52:48AM +0100, Laurent Pinchart wrote:
> > drivers/media/platform/omap3isp/ispqueue.c:399:18: warning: 'pa' may be
> > used uninitialized in this function [-Wuninitialized]
> > 
> > This is a false positive but the compiler has no way to know about it,
> > so initialize the variable to 0.
> > 
> > drivers/media/platform/omap3isp/ispqueue.c:445:6: warning:
> > 'vm_page_prot' may be used uninitialized in this function
> > [-Wuninitialized]
> > 
> > This is a false positive and the compiler should know better. Use
> > uninitialized_var().
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  drivers/media/platform/omap3isp/ispqueue.c |4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/platform/omap3isp/ispqueue.c
> > b/drivers/media/platform/omap3isp/ispqueue.c index 15bf3ea..1388eb7
> > 100644
> > --- a/drivers/media/platform/omap3isp/ispqueue.c
> > +++ b/drivers/media/platform/omap3isp/ispqueue.c
> > @@ -366,7 +366,7 @@ static int isp_video_buffer_prepare_pfnmap(struct
> > isp_video_buffer *buf)
> > unsigned long this_pfn;
> > unsigned long start;
> > unsigned long end;
> > -   dma_addr_t pa;
> > +   dma_addr_t pa = 0;
> 
> Why 0 and not something else arbitrary? :-)
> 
> The value will not be used as far as I can tell. If it gets used it
> certainly is a bug.

If buf->vbuf.length == 0 pa will be used uninitialized. This is clearly a bug, 
but I thought it would be easier to debug if pa was set to 0 in that case 
instead of a random value through uninitialized_var().

> > int ret = -EFAULT;
> > 
> > start = buf->vbuf.m.userptr;
> > 
> > @@ -419,7 +419,7 @@ done:
> >  static int isp_video_buffer_prepare_vm_flags(struct isp_video_buffer
> >  *buf)
> >  {
> > struct vm_area_struct *vma;
> > -   pgprot_t vm_page_prot;
> > +   pgprot_t uninitialized_var(vm_page_prot);
> > unsigned long start;
> > unsigned long end;
> > int ret = -EFAULT;

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] omap3isp: ispqueue: Fix uninitialized variable compiler warnings

2013-01-04 Thread Sakari Ailus
Hi Laurent,

Thanks for the patch.

On Mon, Dec 17, 2012 at 09:52:48AM +0100, Laurent Pinchart wrote:
> drivers/media/platform/omap3isp/ispqueue.c:399:18: warning: 'pa' may be
> used uninitialized in this function [-Wuninitialized]
> 
> This is a false positive but the compiler has no way to know about it,
> so initialize the variable to 0.
> 
> drivers/media/platform/omap3isp/ispqueue.c:445:6: warning:
> 'vm_page_prot' may be used uninitialized in this function
> [-Wuninitialized]
> 
> This is a false positive and the compiler should know better. Use
> uninitialized_var().
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/media/platform/omap3isp/ispqueue.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/omap3isp/ispqueue.c 
> b/drivers/media/platform/omap3isp/ispqueue.c
> index 15bf3ea..1388eb7 100644
> --- a/drivers/media/platform/omap3isp/ispqueue.c
> +++ b/drivers/media/platform/omap3isp/ispqueue.c
> @@ -366,7 +366,7 @@ static int isp_video_buffer_prepare_pfnmap(struct 
> isp_video_buffer *buf)
>   unsigned long this_pfn;
>   unsigned long start;
>   unsigned long end;
> - dma_addr_t pa;
> + dma_addr_t pa = 0;

Why 0 and not something else arbitrary? :-)

The value will not be used as far as I can tell. If it gets used it
certainly is a bug.

>   int ret = -EFAULT;
>  
>   start = buf->vbuf.m.userptr;
> @@ -419,7 +419,7 @@ done:
>  static int isp_video_buffer_prepare_vm_flags(struct isp_video_buffer *buf)
>  {
>   struct vm_area_struct *vma;
> - pgprot_t vm_page_prot;
> + pgprot_t uninitialized_var(vm_page_prot);
>   unsigned long start;
>   unsigned long end;
>   int ret = -EFAULT;

-- 
Cheers,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] omap3isp: ispqueue: Fix uninitialized variable compiler warnings

2012-12-17 Thread Laurent Pinchart
drivers/media/platform/omap3isp/ispqueue.c:399:18: warning: 'pa' may be
used uninitialized in this function [-Wuninitialized]

This is a false positive but the compiler has no way to know about it,
so initialize the variable to 0.

drivers/media/platform/omap3isp/ispqueue.c:445:6: warning:
'vm_page_prot' may be used uninitialized in this function
[-Wuninitialized]

This is a false positive and the compiler should know better. Use
uninitialized_var().

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/omap3isp/ispqueue.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispqueue.c 
b/drivers/media/platform/omap3isp/ispqueue.c
index 15bf3ea..1388eb7 100644
--- a/drivers/media/platform/omap3isp/ispqueue.c
+++ b/drivers/media/platform/omap3isp/ispqueue.c
@@ -366,7 +366,7 @@ static int isp_video_buffer_prepare_pfnmap(struct 
isp_video_buffer *buf)
unsigned long this_pfn;
unsigned long start;
unsigned long end;
-   dma_addr_t pa;
+   dma_addr_t pa = 0;
int ret = -EFAULT;
 
start = buf->vbuf.m.userptr;
@@ -419,7 +419,7 @@ done:
 static int isp_video_buffer_prepare_vm_flags(struct isp_video_buffer *buf)
 {
struct vm_area_struct *vma;
-   pgprot_t vm_page_prot;
+   pgprot_t uninitialized_var(vm_page_prot);
unsigned long start;
unsigned long end;
int ret = -EFAULT;
-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html