[U-Boot-Users] u-boot 1.1.2 and atoi in exports not working

Wolfgang Denk wd at denx.de
Thu Nov 24 16:53:34 CET 2005


Dear John,

in message <6a7ac2300511240637p1b281106k2849ac3bb5a96715 at mail.gmail.com> you wrote:
> 
> > What makes you think atoi() is available in U-Boot?
> 
> I see all these other routines using it.  I figured I could use it as well. ie.

Be careful! Just running "grep" does not mean anything. You  have  to
check on which #ifdef's these lines depend.

> common/hush.c:104:#include <stdlib.h>    /* getenv, atoi */
> common/hush.c:606:      exit (atoi(child->argv[1]));
> common/hush.c:803:              n=atoi(child->argv[1]);
> common/hush.c:2667:     num=atoi(o->data);

For example, the hush shell is a port from the busybox  project,  and
was  changed  only  in the minimal necessary way. And if you look for
example at

common/hush.c:104:#include <stdlib.h>    /* getenv, atoi */

you should check the context:

    ...
    100 #ifdef CFG_HUSH_PARSER
    101 #ifndef __U_BOOT__
    102 #include <ctype.h>     /* isalpha, isdigit */
    103 #include <unistd.h>    /* getpid */
    104 #include <stdlib.h>    /* getenv, atoi */
    ...

Note the "#ifndef __U_BOOT__" part!

> tools/mpc86x_clk.c:205: xin  = atoi(argv[1]);
> tools/mpc86x_clk.c:206: want_gclk2 = atoi(argv[2]);
> tools/mpc86x_clk.c:208:         ppm = atoi(argv[3]);
> tools/ncb.c:14:         port = atoi (argv[1]);

Also, tools/ are tools that are running on the  host  system  -  they
don't have anything in common with U-Boot code.


Summary: there is no atoi() in U-Boot.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In an organization, each person rises to the level of his own  incom-
petency                                         - The Peter Principle




More information about the U-Boot mailing list