[PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]

Michel Dänzer michel at daenzer.net
Fri Dec 21 11:18:25 UTC 2018


On 2018-12-20 3:01 p.m., S, Shirish wrote:
> Initializing structures with { } is known to be problematic since
> it doesn't necessararily initializes all bytes, in case of padding,
> causing random failures when structures are memcmp().
> 
> This patch fixes the structure initialisation compiler error by memsetting
> the entire structure elements instead of only the first one.
> 
> Signed-off-by: Shirish S <shirish.s at amd.com>
> 
> [...]
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index bacdaef..2bfddce 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -320,8 +320,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
>  	}
>  
>  	if (printk_ratelimit()) {
> -		struct amdgpu_task_info task_info = { 0 };
> +		struct amdgpu_task_info task_info;
>  
> +		memset(&task_info, 0, sizeof(amdgpu_task_info));

This doesn't compile:

drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c: In function ‘gmc_v9_0_process_interrupt’:
drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c:325:32: error: ‘amdgpu_task_info’ undeclared (first use in this function)
   memset(&task_info, 0, sizeof(amdgpu_task_info));
                                ^~~~~~~~~~~~~~~~

(Needs to be "sizeof(struct amdgpu_task_info)")


I've reverted this on the internal amd-staging-drm-next branch.

Patches must be tested appropriately (against the target branch),
ideally before submitting them for review. Reviewers are not expected to
look for things which trivially break the build.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the amd-gfx mailing list