linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()
@ 2022-02-07 16:53 Nathan Chancellor
  2022-02-07 19:44 ` Nick Desaulniers
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-02-07 16:53 UTC (permalink / raw)
  To: Yannick Fertre, Philippe Cornu, Benjamin Gaignard
  Cc: Nick Desaulniers, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, llvm, Nathan Chancellor

Clang warns:

  drivers/gpu/drm/stm/ltdc.c:625:2: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
          default:
          ^~~~~~~
  drivers/gpu/drm/stm/ltdc.c:635:2: note: uninitialized use occurs here
          val |= LxPCR_YCEN;
          ^~~
  drivers/gpu/drm/stm/ltdc.c:600:9: note: initialize the variable 'val' to silence this warning
          u32 val;
                 ^
                  = 0
  1 warning generated.

Use a return instead of break in the default case to fix the warning.
Add an error message so that this return is not silent, which could hide
issues in the future.

Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
Link: https://github.com/ClangBuiltLinux/linux/issues/1575
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/stm/ltdc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 5eeb32c9c9ce..447ddde1786c 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -624,7 +624,8 @@ static inline void ltdc_set_ycbcr_config(struct drm_plane *plane, u32 drm_pix_fm
 		break;
 	default:
 		/* RGB or not a YCbCr supported format */
-		break;
+		drm_err(plane->dev, "Unsupported pixel format: %u\n", drm_pix_fmt);
+		return;
 	}
 
 	/* Enable limited range */

base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()
  2022-02-07 16:53 [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config() Nathan Chancellor
@ 2022-02-07 19:44 ` Nick Desaulniers
  2022-02-22 10:54   ` Philippe CORNU
  2022-02-08  8:52 ` Raphael Gallais-Pou
  2022-02-08 15:44 ` yannick Fertre
  2 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2022-02-07 19:44 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Yannick Fertre, Philippe Cornu, Benjamin Gaignard, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, llvm

On Mon, Feb 7, 2022 at 8:53 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Clang warns:
>
>   drivers/gpu/drm/stm/ltdc.c:625:2: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>           default:
>           ^~~~~~~
>   drivers/gpu/drm/stm/ltdc.c:635:2: note: uninitialized use occurs here
>           val |= LxPCR_YCEN;
>           ^~~
>   drivers/gpu/drm/stm/ltdc.c:600:9: note: initialize the variable 'val' to silence this warning
>           u32 val;
>                  ^
>                   = 0
>   1 warning generated.
>
> Use a return instead of break in the default case to fix the warning.
> Add an error message so that this return is not silent, which could hide
> issues in the future.
>
> Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1575
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/gpu/drm/stm/ltdc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 5eeb32c9c9ce..447ddde1786c 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -624,7 +624,8 @@ static inline void ltdc_set_ycbcr_config(struct drm_plane *plane, u32 drm_pix_fm
>                 break;
>         default:
>                 /* RGB or not a YCbCr supported format */
> -               break;
> +               drm_err(plane->dev, "Unsupported pixel format: %u\n", drm_pix_fmt);

This is fine, but in the future you should add an explicit
#include <drm/drm_print.h>
to avoid implicit header dependencies (like the ones that Mingo is
trying to detangle) for the declaration of drm_err. `drm_vprintf`
needs it, too.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> +               return;
>         }
>
>         /* Enable limited range */
>
> base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed
> --
> 2.35.1
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()
  2022-02-07 16:53 [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config() Nathan Chancellor
  2022-02-07 19:44 ` Nick Desaulniers
@ 2022-02-08  8:52 ` Raphael Gallais-Pou
  2022-02-08 15:44 ` yannick Fertre
  2 siblings, 0 replies; 6+ messages in thread
From: Raphael Gallais-Pou @ 2022-02-08  8:52 UTC (permalink / raw)
  To: Nathan Chancellor, Yannick Fertre, Philippe Cornu, Benjamin Gaignard
  Cc: llvm, Nick Desaulniers, linux-kernel, dri-devel, linux-stm32,
	linux-arm-kernel

Hello Nathan,


On 2/7/22 17:53, Nathan Chancellor wrote:
> Clang warns:
>
>   drivers/gpu/drm/stm/ltdc.c:625:2: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>           default:
>           ^~~~~~~
>   drivers/gpu/drm/stm/ltdc.c:635:2: note: uninitialized use occurs here
>           val |= LxPCR_YCEN;
>           ^~~
>   drivers/gpu/drm/stm/ltdc.c:600:9: note: initialize the variable 'val' to silence this warning
>           u32 val;
>                  ^
>                   = 0
>   1 warning generated.
>
> Use a return instead of break in the default case to fix the warning.
> Add an error message so that this return is not silent, which could hide
> issues in the future.
>
> Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1575
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/gpu/drm/stm/ltdc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)


Reviewed-by: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>


Thanks,

Raphaël


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()
  2022-02-07 16:53 [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config() Nathan Chancellor
  2022-02-07 19:44 ` Nick Desaulniers
  2022-02-08  8:52 ` Raphael Gallais-Pou
@ 2022-02-08 15:44 ` yannick Fertre
  2 siblings, 0 replies; 6+ messages in thread
From: yannick Fertre @ 2022-02-08 15:44 UTC (permalink / raw)
  To: Nathan Chancellor, Philippe Cornu, Benjamin Gaignard
  Cc: Nick Desaulniers, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, llvm

Hi Nathan,
Thenks for the patch.

Acked-by: Yannick Fertre <yannick.fertre@foss.st.com>

Best regards

On 2/7/22 17:53, Nathan Chancellor wrote:
> Clang warns:
> 
>    drivers/gpu/drm/stm/ltdc.c:625:2: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>            default:
>            ^~~~~~~
>    drivers/gpu/drm/stm/ltdc.c:635:2: note: uninitialized use occurs here
>            val |= LxPCR_YCEN;
>            ^~~
>    drivers/gpu/drm/stm/ltdc.c:600:9: note: initialize the variable 'val' to silence this warning
>            u32 val;
>                   ^
>                    = 0
>    1 warning generated.
> 
> Use a return instead of break in the default case to fix the warning.
> Add an error message so that this return is not silent, which could hide
> issues in the future.
> 
> Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1575
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>   drivers/gpu/drm/stm/ltdc.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 5eeb32c9c9ce..447ddde1786c 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -624,7 +624,8 @@ static inline void ltdc_set_ycbcr_config(struct drm_plane *plane, u32 drm_pix_fm
>   		break;
>   	default:
>   		/* RGB or not a YCbCr supported format */
> -		break;
> +		drm_err(plane->dev, "Unsupported pixel format: %u\n", drm_pix_fmt);
> +		return;
>   	}
>   
>   	/* Enable limited range */
> 
> base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()
  2022-02-07 19:44 ` Nick Desaulniers
@ 2022-02-22 10:54   ` Philippe CORNU
  2022-02-22 15:23     ` Nathan Chancellor
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe CORNU @ 2022-02-22 10:54 UTC (permalink / raw)
  To: Nick Desaulniers, Nathan Chancellor
  Cc: Yannick Fertre, Benjamin Gaignard, dri-devel, linux-stm32,
	linux-arm-kernel, linux-kernel, llvm



On 2/7/22 8:44 PM, Nick Desaulniers wrote:
> On Mon, Feb 7, 2022 at 8:53 AM Nathan Chancellor <nathan@kernel.org> wrote:
>>
>> Clang warns:
>>
>>    drivers/gpu/drm/stm/ltdc.c:625:2: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
>>            default:
>>            ^~~~~~~
>>    drivers/gpu/drm/stm/ltdc.c:635:2: note: uninitialized use occurs here
>>            val |= LxPCR_YCEN;
>>            ^~~
>>    drivers/gpu/drm/stm/ltdc.c:600:9: note: initialize the variable 'val' to silence this warning
>>            u32 val;
>>                   ^
>>                    = 0
>>    1 warning generated.
>>
>> Use a return instead of break in the default case to fix the warning.
>> Add an error message so that this return is not silent, which could hide
>> issues in the future.
>>
>> Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
>> Link: https://github.com/ClangBuiltLinux/linux/issues/1575
>> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>> ---
>>   drivers/gpu/drm/stm/ltdc.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>> index 5eeb32c9c9ce..447ddde1786c 100644
>> --- a/drivers/gpu/drm/stm/ltdc.c
>> +++ b/drivers/gpu/drm/stm/ltdc.c
>> @@ -624,7 +624,8 @@ static inline void ltdc_set_ycbcr_config(struct drm_plane *plane, u32 drm_pix_fm
>>                  break;
>>          default:
>>                  /* RGB or not a YCbCr supported format */
>> -               break;
>> +               drm_err(plane->dev, "Unsupported pixel format: %u\n", drm_pix_fmt);
> 
> This is fine, but in the future you should add an explicit
> #include <drm/drm_print.h>
> to avoid implicit header dependencies (like the ones that Mingo is
> trying to detangle) for the declaration of drm_err. `drm_vprintf`
> needs it, too.
> 
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 

Hi Nick,
and thank you for having pointing this.

Hi Nathan,
May I ask you please to update your patch changing drm_err(plane->dev, ) 
with DRM_ERROR().


Big thank you,

Philippe :-)



>> +               return;
>>          }
>>
>>          /* Enable limited range */
>>
>> base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed
>> --
>> 2.35.1
>>
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()
  2022-02-22 10:54   ` Philippe CORNU
@ 2022-02-22 15:23     ` Nathan Chancellor
  0 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-02-22 15:23 UTC (permalink / raw)
  To: Philippe CORNU
  Cc: Nick Desaulniers, Yannick Fertre, Benjamin Gaignard, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, llvm

On Tue, Feb 22, 2022 at 11:54:04AM +0100, Philippe CORNU wrote:
> 
> 
> On 2/7/22 8:44 PM, Nick Desaulniers wrote:
> > On Mon, Feb 7, 2022 at 8:53 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > > 
> > > Clang warns:
> > > 
> > >    drivers/gpu/drm/stm/ltdc.c:625:2: warning: variable 'val' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
> > >            default:
> > >            ^~~~~~~
> > >    drivers/gpu/drm/stm/ltdc.c:635:2: note: uninitialized use occurs here
> > >            val |= LxPCR_YCEN;
> > >            ^~~
> > >    drivers/gpu/drm/stm/ltdc.c:600:9: note: initialize the variable 'val' to silence this warning
> > >            u32 val;
> > >                   ^
> > >                    = 0
> > >    1 warning generated.
> > > 
> > > Use a return instead of break in the default case to fix the warning.
> > > Add an error message so that this return is not silent, which could hide
> > > issues in the future.
> > > 
> > > Fixes: 484e72d3146b ("drm/stm: ltdc: add support of ycbcr pixel formats")
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/1575
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > ---
> > >   drivers/gpu/drm/stm/ltdc.c | 3 ++-
> > >   1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> > > index 5eeb32c9c9ce..447ddde1786c 100644
> > > --- a/drivers/gpu/drm/stm/ltdc.c
> > > +++ b/drivers/gpu/drm/stm/ltdc.c
> > > @@ -624,7 +624,8 @@ static inline void ltdc_set_ycbcr_config(struct drm_plane *plane, u32 drm_pix_fm
> > >                  break;
> > >          default:
> > >                  /* RGB or not a YCbCr supported format */
> > > -               break;
> > > +               drm_err(plane->dev, "Unsupported pixel format: %u\n", drm_pix_fmt);
> > 
> > This is fine, but in the future you should add an explicit
> > #include <drm/drm_print.h>
> > to avoid implicit header dependencies (like the ones that Mingo is
> > trying to detangle) for the declaration of drm_err. `drm_vprintf`
> > needs it, too.
> > 
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > 
> 
> Hi Nick,
> and thank you for having pointing this.
> 
> Hi Nathan,
> May I ask you please to update your patch changing drm_err(plane->dev, )
> with DRM_ERROR().

Sure thing, v2 has been sent:

https://lore.kernel.org/r/20220222152045.484610-1-nathan@kernel.org/

I used drm_err() as I saw DRM_ERROR() was deprecated but I get internal
driver consistency is important.

Cheers,
Nathan

> Big thank you,
> 
> Philippe :-)
> 
> 
> 
> > > +               return;
> > >          }
> > > 
> > >          /* Enable limited range */
> > > 
> > > base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed
> > > --
> > > 2.35.1
> > > 
> > 
> > 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-22 15:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 16:53 [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config() Nathan Chancellor
2022-02-07 19:44 ` Nick Desaulniers
2022-02-22 10:54   ` Philippe CORNU
2022-02-22 15:23     ` Nathan Chancellor
2022-02-08  8:52 ` Raphael Gallais-Pou
2022-02-08 15:44 ` yannick Fertre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).