On 24/12/2020 17:10, Julien Grall wrote:
>
>
> On 24/12/2020 17:00, Andrew Cooper wrote:
>> On 24/12/2020 16:49, Julien Grall wrote:
>>> From: Julien Grall <jgr...@amazon.com>
>>>
>>> Clang 11 will throw the following error:
>>>
>>> smmu.c:2284:18: error: cast to smaller integer type 'enum
>>> arm_smmu_arch_version' from 'const void *'
>>> [-Werror,-Wvoid-pointer-to-enum-cast]
>>>          smmu->version = (enum arm_smmu_arch_version)of_id->data;
>>>                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> The error can be prevented by introduce static variable for each SMMU
>>> version and store a pointer for each of them.
>>>
>>> Signed-off-by: Julien Grall <jgr...@amazon.com>
>>
>> You can also fix this by casting through (uintptr_t) instead of (enum
>> arm_smmu_arch_version), which wouldn't involve an extra indirection.
>
> I thought about using a different cast, but it feels just papering
> over the issue.
>
> But I don't see what's the problem with the extra indirection... It is
> self-contained and only used during the IOMMU initialization.

Well - its extra .rodata for the sake of satisfying the compiler in a
specific way.

Irrespective, all of this looks like it ought to be initdata rather than
runtime data, which is probably a bigger deal than worrying about one
extra pointer access.

~Andrew

Reply via email to