Thread (6 messages) 6 messages, 5 authors, 2022-02-22

Re: [PATCH] drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()

From: yannick Fertre <yannick.fertre@foss.st.com>
Date: 2022-02-08 16:23:34
Also in: dri-devel, lkml, 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:
quoted hunk ↗ jump to hunk
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help