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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 21.12.18 um 12:18 schrieb Michel Dänzer:
> 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@xxxxxxx>
>>
>> [...]
>>   
>> 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)")

The coding style guide lines actually document that you should avoid 
types with sizeof and instead use the variables directly.

E.g. use "memset(&task_info, 0, sizeof(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.

Completely agree.

I mean I break things more often than not myself because of our limited 
QA resources, but at least such trivial things should not happen any more.

Regards,
Christian.
_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux