[U-Boot] U-Boot Bug with newer GCC

Marek Vasut
2013-02-02T15:05:21Z

Dear Jeroen Hofstee,

> Hello Albert,
>
> On 02/02/2013 12:32 PM, Albert ARIBAUD wrote:
> >>> Sebastian wrote On 01.02.2013 08:55:
> >>>> we are using u-boot in our embedded system with arm-1136jfs cpu.
> >>>> We recently tried a new toolchain with GCC 4.7.2.
> >>>> If compiled with the new toolchain the feature CONFIG_AUTO_COMPLETE
> >>>> isn't working.
> >
> > [..] AFAIK it has never been seen on mainline code,
>
> The twister board from mainline / current master also has
> this problem. I believe the mt_ventoux will have it as well,
> but can't test it.
>
> > and has been very elusive for those who experience it -- enabling debug
> > or simply adding/removing code makes it go away or reappear, leading me
> > to thinking that some of the added code either does a data abort itself,
> > or causes one in the mainline code it calls upon.
>
> yes, it is confusing. The following patch will e.g. make the
> trap go away on the twister. Yet there is nothing wrong with the
> original code it touches (or I fail to see what it is).
>
> Regards,
> Jeroen
>
> diff --git a/common/command.c b/common/command.c
> index 50c8429..520bd39 100644
> --- a/common/command.c
> +++ b/common/command.c
> @@ -185,7 +185,6 @@ static int complete_cmdv(int argc, char * const
> argv[], char last_char, int maxv
> cmd_tbl_t *cmdtp = ll_entry_start(cmd_tbl_t, cmd);
> const int count = ll_entry_count(cmd_tbl_t, cmd);
> const cmd_tbl_t *cmdend = cmdtp + count;
> - const char *p;
> int len, clen;
> int n_found = 0;
> const char *cmd;
> @@ -224,11 +223,7 @@ static int complete_cmdv(int argc, char * const
> argv[], char last_char, int maxv
> * Some commands allow length modifiers (like "cp.b");
> * compare command name only until first dot.
> */
> - p = strchr(cmd, '.');
> - if (p == NULL)
> - len = strlen(cmd);
> - else
> - len = p - cmd;
> + len = strlen(cmd);
>
> /* return the partial matches */
> for (; cmdtp != cmdend; cmdtp++) {

Could it be that 'cmd' is possibly not zero-terminated string?

Best regards,
Marek Vasut