[Mesa-dev] [PATCH] gallium: fix clang warnings

Nicolai Hähnle nhaehnle at gmail.com
Wed Sep 7 13:59:38 UTC 2016


On 07.09.2016 14:40, Jan Vesely wrote:
> On Wed, 2016-09-07 at 10:12 +0200, Nicolai Hähnle wrote:
>> On 07.09.2016 09:38, Michel Dänzer wrote:
>>>
>>> On 07/09/16 12:29 AM, Nicolai Hähnle wrote:
>>>>
>>>> On 06.09.2016 16:37, Martina Kollarova wrote:
>>>>>
>>>>> 1. Variable 'hole' is uninitialized when used here [-
>>>>> Wuninitialized]
>>>>> 2. Comparison of constant -1 with expression of type 'unsigned
>>>>> int' is
>>>>> always
>>>>>    false [-Wtautological-constant-out-of-range-compare]
>>>>> ---
>>>>>  src/gallium/winsys/radeon/drm/radeon_drm_bo.c     | 2 +-
>>>>>  src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 5 -----
>>>
>>> BTW, please split this up into one patch per component next time.
>>>
>>>
>>>>
>>>>>
>>>>> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
>>>>> b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
>>>>> index 56aab48..23ee8d5 100644
>>>>> --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
>>>>> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
>>>>> @@ -200,7 +200,7 @@ static uint64_t radeon_bomgr_find_va(struct
>>>>> radeon_drm_winsys *rws,
>>>>>  static void radeon_bomgr_free_va(struct radeon_drm_winsys
>>>>> *rws,
>>>>>                                   uint64_t va, uint64_t size)
>>>>>  {
>>>>> -    struct radeon_bo_va_hole *hole;
>>>>> +    struct radeon_bo_va_hole *hole = NULL;
>>>>
>>>> This is a false positive, [...]
>>>
>>> That's debatable, but anyway it's probably better addressed by
>>> porting
>>> https://cgit.freedesktop.org/mesa/drm/commit/?id=b214b05ccd433c484a
>>> 6a65e491a1a51b19e4811d
>>> to src/util/list.h .
>>
>> You're right, that should fix it. Separately, it might be a good idea
>> to
>> move the declaration of hole down into the scopes where it's actually
>> used.
>
> Hi, is there a reason not to use 'offsetof' from stddef.h instead of
> pointer arithmetics? it's C standard, so it should be cross platform
> enough.

offsetof expects a type as argument instead of a "sample", so it cannot 
be used here without typeof - and that isn't cross platform (AFAIK).

To be honest, I wouldn't mind changing container_of to use a type as 
well, that would also be in line with what the kernel has.

Nicolai

>
> Jan
>
>>
>> Nicolai
>>
>>>
>>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list