[U-Boot] [PATCH v3] sandbox: fix compiler warning

Allen Martin amartin at nvidia.com
Wed Jan 23 22:05:27 CET 2013


On Tue, Jan 22, 2013 at 10:46:03PM -0800, Albert ARIBAUD wrote:
> Hi Allen,
> 
> On Tue, 22 Jan 2013 15:11:21 -0800, Allen Martin <amartin at nvidia.com>
> wrote:
> 
> > Add back return statement to fix compiler warning about control flow
> > reaching end of non void function that was introduced with:
> > 
> > 	e05e5de arm: move C runtime setup code in crt0.S
> > 
> > Signed-off-by: Allen Martin <amartin at nvidia.com>
> > Acked-by: Simon Glass <sjg at chromium.org>
> > ---
> >  arch/sandbox/cpu/start.c |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
> > index 7603bf9..5287fd5 100644
> > --- a/arch/sandbox/cpu/start.c
> > +++ b/arch/sandbox/cpu/start.c
> > @@ -122,4 +122,7 @@ int main(int argc, char *argv[])
> >  	 * never return.
> >  	 */
> >  	board_init_f(0);
> > +
> > +	/* NOTREACHED - board_init_f() does not return */
> > +	return 0;
> >  }
> 
> Shouldn't the function be given '__attribute__((noreturn))' rather than
> adding a non-executed 'return 0' to it?
> 

The function in question is sandbox main(), and it can return if there
was an error prior to calling board_init_f().  Here's the whole
function for context:

int main(int argc, char *argv[])
{
        struct sandbox_state *state;
        int err;

        err = state_init();
        if (err)
                return err;

        state = state_get_current();
        if (os_parse_args(state, argc, argv))
                return 1;

        /*
         * Do pre- and post-relocation init, then start up
        U-Boot. This will
         * never return.
         */
        board_init_f(0);

        /* NOTREACHED - board_init_f() does not return */
        return 0;
}


-Allen
-- 
nvpublic


More information about the U-Boot mailing list