[Intel-xe] [PATCH 2/3] drm/i915: Fix uninitialized variable warning

Lucas De Marchi lucas.demarchi at intel.com
Wed Oct 18 16:54:34 UTC 2023


On Wed, Oct 18, 2023 at 01:58:25PM +0200, Michał Winiarski wrote:
>When used with Xe, "val" uses as function argument name clashes with
>"val" used inside iosys_map_* macro causing the build to fail with:
>
>drivers/gpu/drm/i915/display/intel_dsb.c:87:46: error: variable 'val' is uninitialized when used within its own initialization [-Werror,-Wuninitialized]
>
>Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>

I'd rather change the macro so it doesn't use a commonly-used variable
name. I usually use a _ suffix on macro arguments because of that.

I should had done that in commit e62f25e8b3cd ("iosys-map: Add a few more helpers")

wouldn't this be better?

diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 1b06d074ade0..78b3856c475a 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -414,11 +414,11 @@ static inline void iosys_map_memset(struct iosys_map *dst, size_t offset,
   * supported), use iosys_map_memcpy_to()
   */
  #define iosys_map_wr(map__, offset__, type__, val__) ({				\
-	type__ val = (val__);							\
+	type__ val_ = (val__);							\
  	if ((map__)->is_iomem) {						\
-		__iosys_map_wr_io(val, (map__)->vaddr_iomem + (offset__), type__);\
+		__iosys_map_wr_io(val_, (map__)->vaddr_iomem + (offset__), type__);\
  	} else {								\
-		__iosys_map_wr_sys(val, (map__)->vaddr + (offset__), type__);	\
+		__iosys_map_wr_sys(val_, (map__)->vaddr + (offset__), type__);	\
  	}									\
  })


More information about the Intel-xe mailing list