diff mbox

[U-Boot] video: ipu_disp: squash clang warning

Message ID 1402947663-20632-1-git-send-email-jeroen@myspectrum.nl
State Changes Requested
Headers show

Commit Message

Jeroen Hofstee June 16, 2014, 7:41 p.m. UTC
Since &rgb2ycbcr_coeff and friends are declared const, but
assigned to a void pointer, clang will warn that the const
is implicity casted away. Add const to indicate the pointer
points to const data to get rid of these warnings.

Cc: Stefano Babic <sbabic@denx.de>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
---
 drivers/video/ipu_disp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Troy Kisky June 16, 2014, 7:52 p.m. UTC | #1
On 6/16/2014 12:41 PM, Jeroen Hofstee wrote:
> Since &rgb2ycbcr_coeff and friends are declared const, but
> assigned to a void pointer, clang will warn that the const
> is implicity casted away. Add const to indicate the pointer
> points to const data to get rid of these warnings.
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
> ---
>  drivers/video/ipu_disp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/ipu_disp.c b/drivers/video/ipu_disp.c
> index cefd2dc..31b5a10 100644
> --- a/drivers/video/ipu_disp.c
> +++ b/drivers/video/ipu_disp.c
> @@ -33,7 +33,7 @@ enum csc_type_t {
>  
>  struct dp_csc_param_t {
>  	int mode;
> -	void *coeff;
> +	void * const coeff;
>  };
>  
>  #define SYNC_WAVE 0
> 

Doesn't this says the pointer is constant, not that it points to constant data?
So, commit log needs updated or
const void *coeff;

Troy
Jeroen Hofstee June 16, 2014, 8:03 p.m. UTC | #2
Hello Troy,

On ma, 2014-06-16 at 12:52 -0700, Troy Kisky wrote:
> On 6/16/2014 12:41 PM, Jeroen Hofstee wrote:
> > Since &rgb2ycbcr_coeff and friends are declared const, but
> > assigned to a void pointer, clang will warn that the const
> > is implicity casted away. Add const to indicate the pointer
> > points to const data to get rid of these warnings.
> > 
> > Cc: Stefano Babic <sbabic@denx.de>
> > Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
> > ---
> >  drivers/video/ipu_disp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/video/ipu_disp.c b/drivers/video/ipu_disp.c
> > index cefd2dc..31b5a10 100644
> > --- a/drivers/video/ipu_disp.c
> > +++ b/drivers/video/ipu_disp.c
> > @@ -33,7 +33,7 @@ enum csc_type_t {
> >  
> >  struct dp_csc_param_t {
> >  	int mode;
> > -	void *coeff;
> > +	void * const coeff;
> >  };
> >  
> >  #define SYNC_WAVE 0
> > 
> 
> Doesn't this says the pointer is constant, not that it points to constant data?
> So, commit log needs updated or
> const void *coeff;

yup, it does. Thanks. The patch should be updated actually.

Regards,
Jeroen
Jeroen Hofstee June 16, 2014, 8:37 p.m. UTC | #3
On ma, 2014-06-16 at 12:52 -0700, Troy Kisky wrote:
> On 6/16/2014 12:41 PM, Jeroen Hofstee wrote:
> > Since &rgb2ycbcr_coeff and friends are declared const, but
> > assigned to a void pointer, clang will warn that the const
> > is implicity casted away. Add const to indicate the pointer
> > points to const data to get rid of these warnings.
> > 
> > Cc: Stefano Babic <sbabic@denx.de>
> > Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
> > ---
> >  drivers/video/ipu_disp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/video/ipu_disp.c b/drivers/video/ipu_disp.c
> > index cefd2dc..31b5a10 100644
> > --- a/drivers/video/ipu_disp.c
> > +++ b/drivers/video/ipu_disp.c
> > @@ -33,7 +33,7 @@ enum csc_type_t {
> >  
> >  struct dp_csc_param_t {
> >  	int mode;
> > -	void *coeff;
> > +	void * const coeff;
> >  };
> >  
> >  #define SYNC_WAVE 0
> > 
> 
> Doesn't this says the pointer is constant, not that it points to constant data?
> So, commit log needs updated or
> const void *coeff;

The reason I wrongly changed it from void const * to void * const was to
circumvent gcc complaining with:

drivers/video/ipu_disp.c: In function ‘ipu_dp_csc_setup’:
drivers/video/ipu_disp.c:393:8: warning: assignment discards ‘const’
qualifier from pointer target type [enabled by default]

This can be solved with:

@@ -390,7 +390,7 @@ void ipu_dp_csc_setup(int dp, struct dp_csc_param_t
dp_csc_param,
                __raw_writel(reg, DP_COM_CONF());
        }
-       coeff = dp_csc_param.coeff;
+       coeff = (const int (*)[5][3]) dp_csc_param.coeff;
 
        if (coeff) {
                __raw_writel(mask_a((*coeff)[0][0]) |


But I am not too happy with that. Happen to know a better way?

Regards,
Jeroen
diff mbox

Patch

diff --git a/drivers/video/ipu_disp.c b/drivers/video/ipu_disp.c
index cefd2dc..31b5a10 100644
--- a/drivers/video/ipu_disp.c
+++ b/drivers/video/ipu_disp.c
@@ -33,7 +33,7 @@  enum csc_type_t {
 
 struct dp_csc_param_t {
 	int mode;
-	void *coeff;
+	void * const coeff;
 };
 
 #define SYNC_WAVE 0