[PATCH 2/2] drm/amdgpu: fix compiler warning

Christian König ckoenig.leichtzumerken at gmail.com
Tue Mar 30 13:12:31 UTC 2021


Am 30.03.21 um 15:10 schrieb Chen, Guchun:
> [AMD Public Use]
>
> Inline comments after yours'.
>
> Regards,
> Guchun
>
> -----Original Message-----
> From: Koenig, Christian <Christian.Koenig at amd.com>
> Sent: Tuesday, March 30, 2021 6:40 PM
> To: Chen, Guchun <Guchun.Chen at amd.com>; amd-gfx at lists.freedesktop.org; Zhang, Hawking <Hawking.Zhang at amd.com>
> Subject: Re: [PATCH 2/2] drm/amdgpu: fix compiler warning
>
> Am 30.03.21 um 12:02 schrieb Guchun Chen:
>> warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
>>     int write = !(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY);
> Well there seems to be some kind of bug in the compiler if it complains about the code below.
> [Guchun]From linux coding style's perspective, we shall put the declarations together, separated from code by one blank line, right?

Correct, yes. I don't mind blank lines when you have for example some 
consts, but others sometimes complain about that.

>
>> Signed-off-by: Guchun Chen <guchun.chen at amd.com>
>> ---
>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 --
>>    1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index 722efd86718e..2a6fc0556386 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -824,7 +824,6 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,
>>    	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
>>    	struct amdgpu_ttm_tt *gtt = (void *)ttm;
>>    	int r;
>> -
> Better have variable like "r" and "i" declared last.
> [Guchun]Will send v2 to address this if you don't have objection to this patch.

Thanks,
Christian.

>
> Christian.
>
>>    	int write = !(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY);
>>    	enum dma_data_direction direction = write ?
>>    		DMA_BIDIRECTIONAL : DMA_TO_DEVICE; @@ -861,7 +860,6 @@ static void
>> amdgpu_ttm_tt_unpin_userptr(struct ttm_device *bdev,
>>    {
>>    	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
>>    	struct amdgpu_ttm_tt *gtt = (void *)ttm;
>> -
>>    	int write = !(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY);
>>    	enum dma_data_direction direction = write ?
>>    		DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx



More information about the amd-gfx mailing list