Skip to contentSkip to conversation

drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()

PATCH In review Nathan Chancellor 2 participants 2 messages Feb 22, 2022 – Feb 25, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/stm: Avoid using val uninitialized in ltdc_set_ycbcr_config()

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.

---

v1 -> v2: https://lore.kernel.org/r/[email protected]/

* Use DRM_ERROR() instead of drm_err() (Philippe).

* Collect tags from v1, as nothing substantial has changed.

 drivers/gpu/drm/stm/ltdc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/ltdc.c +2 -1
index 5eeb32c9c9ce..c9bc4ccb6d43 100644
@@ -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_ERROR("Unsupported pixel format: %u\n", drm_pix_fmt);
+		return;
 	}
 
 	/* Enable limited range */

base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed

Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 24 lines · 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.

Quoted 5 lines

---

v1 -> v2: https://lore.kernel.org/r/[email protected]/

* Use DRM_ERROR() instead of drm_err() (Philippe).

Hi Nathan,

Applied on drm-misc-next.
Many thanks for your patch,
Philippe :-)

Quoted 22 lines

* Collect tags from v1, as nothing substantial has changed.

  drivers/gpu/drm/stm/ltdc.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/ltdc.c +2 -1
index 5eeb32c9c9ce..c9bc4ccb6d43 100644
@@ -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_ERROR("Unsupported pixel format: %u\n", drm_pix_fmt);
+		return;
  	}
 
  	/* Enable limited range */

base-commit: 542898c5aa5c6a3179dffb1d1606884a63f75fed