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

Upadhyay, Tejas tejas.upadhyay at intel.com
Thu Oct 19 12:55:31 UTC 2023



> -----Original Message-----
> From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of Lucas
> De Marchi
> Sent: Wednesday, October 18, 2023 10:25 PM
> To: Winiarski, Michal <michal.winiarski at intel.com>
> Cc: intel-xe at lists.freedesktop.org
> Subject: Re: [Intel-xe] [PATCH 2/3] drm/i915: Fix uninitialized variable warning
> 
> 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__);	\
>   	}
> 	\

Prefix _ in defines is general practice to avoid use of same name rest execution of code. So it looks ok to me,

Acked-by: Tejas Upadhyay <tejas.upadhyay at intel.com>

>   })


More information about the Intel-xe mailing list