Hi Wolfgang

On Wed, Nov 9, 2011 at 9:49 AM, Wolfgang Denk <w...@denx.de> wrote:
> Dear Simon Glass,
>
> In message 
> <capnjgz15f_gva5+mm1em-l2smxt1waatxqikuhoqat893t9...@mail.gmail.com> you 
> wrote:
>>
>> This discussion was regarding the need to #ifdef the variable declaration, 
>> viz:
>>
>> #if defined(THING1) || defined(THING2)
>> const char *cat;
>> #endif
>>
>> ...
>>
>>
>> #ifdef THING1
>>    cat = getenv("cat");
>>
>>    send_back(cat);
>> #endif
>>
>> ....
>>
>> #ifdef THING2
>>    cat = check_outside("cat");
>>
>>    if (cat)
>>       wibble(cat);
>> #endif
>>
>>
>> and whether the top bit would be better as:
>>
>> __maybe_unused const char *cat;
>>
>> But more generally, lots of #ifdefs do make the code harder to read,
>> and potentially more brittle in the face of config changes.
>
> I  would like to see only a minimal number of "__maybe_unused" in the
> code - in cases, where this is the way that hurts least.
>
> In the examples above, it might be better to use local blocks, like:
>
> #ifdef THING1
>        {
>                const char *cat = getenv("cat");
>
>                send_back(cat);
>        }
> #endif

I honestly think most of these cases can be factored out into functions.
The compiler should inline them anyway so the overhead should be zero.
The various board.c files are a prime example of where this should be
done as a matter of principle to reduce the complexity and lenght of
the primary function anyway

Regards,

Graeme
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to