public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] arm: Correct build error introduced by getenv_ulong() patch
Date: Tue, 08 Nov 2011 20:46:46 +0100	[thread overview]
Message-ID: <4EB98726.8090104@aribaud.net> (raw)
In-Reply-To: <CAPnjgZ2PcTHRCG5Ahdf19D2siv879i7a3QmtG2HcgfuTd+WBUA@mail.gmail.com>

Le 08/11/2011 16:57, Simon Glass a ?crit :
> Hi Detlev,
>
> On Tue, Nov 8, 2011 at 1:20 AM, Detlev Zundel<dzu@denx.de>  wrote:
>> Hi Mike,
>>
>>> On Monday 31 October 2011 17:06:46 Simon Glass wrote:
>>>> On Sun, Oct 30, 2011 at 5:44 PM, Mike Frysinger wrote:
>>>>> On Sunday 23 October 2011 23:44:35 Simon Glass wrote:
>>>>>> --- a/arch/arm/lib/board.c
>>>>>> +++ b/arch/arm/lib/board.c
>>>>>>
>>>>>>        flash_size = flash_init();
>>>>>>        if (flash_size>  0) {
>>>>>>   # ifdef CONFIG_SYS_FLASH_CHECKSUM
>>>>>> +             char *s = getenv("flashchecksum");
>>>>>> +
>>>>>>                print_size(flash_size, "");
>>>>>>                /*
>>>>>>                 * Compute and print flash CRC if flashchecksum is set to
>>>>>> 'y' *
>>>>>>                 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
>>>>>>                 */
>>>>>> -             s = getenv("flashchecksum");
>>>>>>                if (s&&  (*s == 'y')) {
>>>>>>                        printf("  CRC: %08X", crc32(0,
>>>>>>                                (const unsigned char *)
>>>>>> CONFIG_SYS_FLASH_BASE, @@ -566,9 +567,12 @@ void board_init_r(gd_t *id,
>>>>>> ulong dest_addr) /* Initialize from environment */
>>>>>>        load_addr = getenv_ulong("loadaddr", 16, load_addr);
>>>>>>   #if defined(CONFIG_CMD_NET)
>>>>>> -     s = getenv("bootfile");
>>>>>> -     if (s != NULL)
>>>>>> -             copy_filename(BootFile, s, sizeof(BootFile));
>>>>>> +     {
>>>>>> +             char *s = getenv("bootfile");
>>>>>> +
>>>>>> +             if (s != NULL)
>>>>>> +                     copy_filename(BootFile, s, sizeof(BootFile));
>>>>>> +     }
>>>>>>   #endif
>>>>>
>>>>> seems like a better solution would be to use at the top:
>>>>>         __maybe_unused char *s;
>>>>>
>>>>> also, shouldn't these be "const char *s" ?
>>>>
>>>> We can certainly do this and I agree it is easier than #ifdefs. Does
>>>> it introduce the possibility that one day the code will stop using the
>>>> variable but it will still be declared? Is the fact that we need the
>>>> #ifdefs an indication that the function should be too long and should
>>>> be refactored? it in fact better to have these explicit so we can see
>>>> them for the ugliness they are?
>>>
>>> yes, you're right that it does leave the door open to the variable being
>>> declared, never used, and gcc not emitting a warning about it.
>>>
>>> both setups suck, but i'd lean towards the less-ifdef state ... wonder if
>>> Wolfgang has a preference.
>>
>> Personally, I think that the nuisance of a potential unused variable is
>> less of an issue than the actual _problems_ that ifdefs induce.
>
> Yes the #ifdefs are a pain. I am working on a replacement for board.c
> - so far I have split things into functions. Next I need to look at
> Graeme's initcall patch.

I don't think 'ifdefs are' necessarily 'a pain'. They cater for a need, 
that is, to mark that some code depends on some condition. I find it 
*normal* that a checksum-related variable is conditioned on the checksum 
macro being defined.

> Regards,
> Simon

Amicalement,
-- 
Albert.

  reply	other threads:[~2011-11-08 19:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24  0:14 [U-Boot] [PATCH] arm: Correct build error introduced by getenv_ulong() patch Simon Glass
2011-10-24  3:44 ` [U-Boot] [PATCH v2] " Simon Glass
2011-10-24 19:13   ` Wolfgang Denk
2011-10-25  6:52     ` Albert ARIBAUD
2011-10-25  7:50       ` Wolfgang Denk
2011-10-25 18:21         ` Albert ARIBAUD
2011-10-25 18:26           ` Simon Glass
2011-10-25 19:36           ` Wolfgang Denk
2011-10-25 19:41             ` Simon Glass
2011-10-31  0:44   ` Mike Frysinger
2011-10-31 21:06     ` Simon Glass
2011-10-31 21:40       ` Mike Frysinger
2011-11-08  9:20         ` Detlev Zundel
2011-11-08 15:57           ` Simon Glass
2011-11-08 19:46             ` Albert ARIBAUD [this message]
2011-11-08 22:28               ` Simon Glass
2011-11-08 22:49                 ` Wolfgang Denk
2011-11-08 23:18                   ` Graeme Russ
2011-11-09 13:45                     ` Detlev Zundel
2011-11-09 14:30                       ` Simon Glass
2011-11-09 14:11                   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EB98726.8090104@aribaud.net \
    --to=albert.u.boot@aribaud.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox