[U-Boot] unused-const-variable warnings in FSL DDR driver

york sun york.sun at nxp.com
Thu Feb 9 17:30:09 UTC 2017


On 02/09/2017 09:17 AM, Thomas Schaefer wrote:
>
>> On 02/09/2017 02:32 AM, Thomas Schaefer wrote:
>>> Hi York,
>>>
>>>
>>>
>>> When compiling latest u-boot with gcc 6.3 compiler, I get several
>>> 'unused-const-variable' warnings in options.c file of FSL DDR driver.
>>> Affected variables are for (DIMM_SLOTS_PER_CTLR==2) configuration (e.g.
>> dual_0S[4]) and warnings could be fixed with the patch applied.
>>>
>>>
>>>
>>> What do you think?
>>
>> Thomas,
>>
>> Thanks for bringing it to my attention. I understand GCC 6 may have more
>> warnings. The proposed patch is OK in logic but it increases the size of code
>> unnecessarily. Can you come up with a different fix?
>>
>> I can come back to check after I finish my work on hand.
>>
>> York
>
> Hi York,
>
> not sure if I understand this correctly, but why is code size increased when these
> variables are not defined? I think code size is decreased instead as these variables
> are no longer defined if not needed.
>
> I also don't see a way to achieve this in a different way as the variables are defined
> differently for DDR2, DDR3 and DDR4.
>
>

Wait a minute, did you generate the patch backward? Your patch shows 
removing "#if CONFIG_DIMM_SLOTS_PER_CTLR==2" which doesn't exist in 
current code. If the logic is reversed, then yes, you are reducing the 
size. Can GCC 6 optimize out the unused data? If yes, maybe we can use 
__maybe_unused to get rid of the warning?

York


More information about the U-Boot mailing list