Fix incorrect use of getenv() before relocation
PATCH 1/1 Fix incorrect use of getenv() before relocation
A large number of boards incorrectly used getenv() in their board init code running before relocation. In some cases this caused U-Boot to hang when certain environment variables grew too long.
Fix the code to use getenv_r().
--- board/LEOX/elpt860/elpt860.c | 5 +++-- board/RRvision/RRvision.c | 10 ++++++---- board/actux1/actux1.c | 9 +++++---- board/actux2/actux2.c | 9 +++++---- board/actux3/actux3.c | 7 ++++--- board/amcc/acadia/acadia.c | 7 ++++--- board/amcc/bamboo/bamboo.c | 7 ++++--- board/amcc/bluestone/bluestone.c | 7 ++++--- board/amcc/bubinga/bubinga.c | 7 ++++--- board/amcc/canyonlands/canyonlands.c | 7 ++++--- board/amcc/ebony/ebony.c | 7 ++++--- board/amcc/katmai/katmai.c | 7 ++++--- board/amcc/kilauea/kilauea.c | 7 ++++--- board/amcc/luan/luan.c | 7 ++++--- board/amcc/makalu/makalu.c | 7 ++++--- board/amcc/ocotea/ocotea.c | 9 +++++---- board/amcc/redwood/redwood.c | 7 ++++--- board/amcc/sequoia/sequoia.c | 7 ++++--- board/amcc/taihu/taihu.c | 7 ++++--- board/amcc/taishan/taishan.c | 9 +++++---- board/amcc/walnut/walnut.c | 7 ++++--- board/amcc/yosemite/yosemite.c | 7 ++++--- board/amcc/yucca/yucca.c | 7 ++++--- board/amirix/ap1000/ap1000.c | 24 ++++++++++++++---------- board/avnet/fx12mm/fx12mm.c | 17 ++++++++--------- board/c2mon/c2mon.c | 10 ++++++---- board/digsy_mtc/digsy_mtc.c | 9 +++++---- board/etx094/etx094.c | 16 +++++++--------- board/gdsys/405ep/dlvision-10g.c | 7 ++++--- board/gdsys/405ep/io.c | 7 ++++--- board/gdsys/405ep/iocon.c | 7 ++++--- board/gdsys/dlvision/dlvision.c | 7 ++++--- board/gdsys/gdppc440etx/gdppc440etx.c | 7 ++++--- board/gdsys/intip/intip.c | 7 ++++--- board/gdsys/neo/neo.c | 7 ++++--- board/gw8260/gw8260.c | 8 ++++---- board/hermes/hermes.c | 16 +++++++--------- board/ixdp425/ixdp425.c | 7 ++++--- board/lwmon5/lwmon5.c | 7 ++++--- board/micronas/vct/vct.c | 7 ++++--- board/ml2/ml2.c | 18 +++++++----------- board/mosaixtech/icon/icon.c | 7 ++++--- board/pcs440ep/pcs440ep.c | 7 ++++--- board/prodrive/alpr/alpr.c | 9 +++++---- board/prodrive/p3mx/p3mx.c | 7 ++++--- board/prodrive/p3p440/p3p440.c | 7 ++++--- board/prodrive/pdnb3/pdnb3.c | 7 ++++--- board/quad100hd/quad100hd.c | 7 ++++--- board/quantum/quantum.c | 10 ++++++---- board/rbc823/rbc823.c | 9 +++++---- board/socrates/socrates.c | 12 +++++++----- board/svm_sc8xx/svm_sc8xx.c | 32 +++++++++++++++++--------------- board/t3corp/t3corp.c | 7 ++++--- board/ti/omap5912osk/omap5912osk.c | 7 ++++--- board/tqc/tqm8260/tqm8260.c | 8 ++++---- board/tqc/tqm8272/tqm8272.c | 8 ++++++-- board/tqc/tqm85xx/tqm85xx.c | 19 +++++++++++-------- board/tqc/tqm8xx/tqm8xx.c | 18 ++++++++++-------- board/xes/common/board.c | 17 +++++++++++------ board/xes/xpedite1000/xpedite1000.c | 21 +++++++++++---------- board/zeus/zeus.c | 7 ++++--- 61 files changed, 324 insertions(+), 260 deletions(-)
board/LEOX/elpt860/elpt860.c +3 -2
@@ -169,9 +169,10 @@ int board_early_init_f (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf)); -if (!s ||strncmp (s,"ELPT860" ,7 )) +if ((i <0 ) ||strncmp (buf,"ELPT860" ,7 ))printf ("### No HW ID - assuming ELPT860\n" );return (0 );/* success */
board/RRvision/RRvision.c +6 -4
@@ -93,14 +93,16 @@ const uint sdram_table[] =int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: RRvision " ); -for (; s && *s; ++s) { -if (*s ==' ' ) +for (i=0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; -putc (*s); +putc (buf[i]); }putc ('\n' );
board/actux1/actux1.c +5 -4
@@ -89,14 +89,15 @@ int board_init (void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: AcTux-1 rev." );putc (ACTUX1_BOARDREL +'A' -1 ); -if (s !=NULL ) { -puts (", serial# " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
board/actux2/actux2.c +5 -4
@@ -96,14 +96,15 @@ int board_init (void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: AcTux-2 rev." );putc (ACTUX2_BOARDREL +'A' -1 ); -if (s !=NULL ) { -puts (", serial# " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
board/actux3/actux3.c +4 -3
@@ -111,14 +111,15 @@ int board_init (void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: AcTux-3 rev." );putc (ACTUX3_BOARDREL +'A' -1 ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/acadia/acadia.c +4 -3
@@ -102,15 +102,16 @@ int misc_init_f(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));u8 rev; rev =in8 (CONFIG_SYS_CPLD_BASE +0 );printf ("Board: Acadia - AMCC PPC405EZ Evaluation Board, Rev. %X" , rev); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/bamboo/bamboo.c +4 -3
@@ -440,12 +440,13 @@ int board_early_init_f(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Bamboo - AMCC PPC440EP Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/bluestone/bluestone.c +4 -3
@@ -78,13 +78,14 @@ int board_early_init_f(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: Bluestone Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/bubinga/bubinga.c +4 -3
@@ -53,13 +53,14 @@ int board_early_init_f(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: Bubinga - AMCC PPC405EP Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/canyonlands/canyonlands.c +4 -3
@@ -293,7 +293,8 @@ int checkboard(void) {struct board_bcsr *bcsr_data = (struct board_bcsr *)CONFIG_SYS_BCSR_BASE ; -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));if (pvr_460ex ()) {printf ("Board: Canyonlands - AMCC PPC460EX Evaluation Board" );
@@ -319,9 +320,9 @@ int checkboard(void)printf (", Rev. %X" ,in_8 (&bcsr_data->cpld_rev)); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/ebony/ebony.c +4 -3
@@ -92,12 +92,13 @@ int board_early_init_f(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Ebony - AMCC PPC440GP Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/katmai/katmai.c +4 -3
@@ -236,12 +236,13 @@ int board_early_init_f (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Katmai - AMCC 440SPe Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/kilauea/kilauea.c +4 -3
@@ -307,16 +307,17 @@ int board_pcie_last(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));if (is_405exr ())printf ("Board: Haleakala - AMCC PPC405EXr Evaluation Board" );else printf ("Board: Kilauea - AMCC PPC405EX Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }printf (" (CPLD rev. %ld)\n" , gd->board_type);
board/amcc/luan/luan.c +4 -3
@@ -105,13 +105,14 @@ int misc_init_r(void)************************************************************************/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Luan - AMCC PPC440SP Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/makalu/makalu.c +4 -3
@@ -224,13 +224,14 @@ int misc_init_r(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Makalu - AMCC PPC405EX Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/ocotea/ocotea.c +5 -4
@@ -200,12 +200,13 @@ int board_early_init_f (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board" ); -if (s !=NULL ) { -puts (", serial# " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
board/amcc/redwood/redwood.c +4 -3
@@ -200,12 +200,13 @@ int board_early_init_f(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Redwood - AMCC 460SX Reference Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/sequoia/sequoia.c +4 -3
@@ -331,7 +331,8 @@ int misc_init_r(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));u8 rev;u32 clock =get_async_pci_freq ();
@@ -344,9 +345,9 @@ int checkboard(void) rev =in_8 ((void *)(CONFIG_SYS_BCSR_BASE +0 ));printf (", Rev. %X, PCI-Async=%d MHz" , rev, clock /1000000 ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/taihu/taihu.c +4 -3
@@ -65,13 +65,14 @@ int board_early_init_f(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: Taihu - AMCC PPC405EP Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/taishan/taishan.c +5 -4
@@ -193,12 +193,13 @@ int misc_init_r(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Taishan - AMCC PPC440GX Evaluation Board" ); -if (s !=NULL ) { -puts (", serial# " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
board/amcc/walnut/walnut.c +4 -3
@@ -67,7 +67,8 @@ int board_early_init_f(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));uint pvr =get_pvr ();if (pvr ==PVR_405GPR_RB ) {
@@ -76,9 +77,9 @@ int checkboard(void)puts ("Board: Walnut - AMCC PPC405GP Evaluation Board" ); } -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/yosemite/yosemite.c +4 -3
@@ -188,7 +188,8 @@ int misc_init_r (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));u8 rev;u32 clock =get_async_pci_freq ();
@@ -201,9 +202,9 @@ int checkboard(void) rev =in_8 ((void *)(CONFIG_SYS_BCSR_BASE +0 ));printf (", Rev. %X, PCI-Async=%d MHz" , rev, clock /1000000 ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amcc/yucca/yucca.c +4 -3
@@ -542,12 +542,13 @@ int board_early_init_f (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: Yucca - AMCC 440SPe Evaluation Board" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/amirix/ap1000/ap1000.c +14 -10
@@ -37,8 +37,8 @@ int board_pre_init (void)/** serial number and platform display at startup */ int checkboard (void ) { -char *s =getenv ("serial#" ); -char *e; +char buf[64 ]; +int l =getenv_f ("serial#" , buf,sizeof (buf));/* After a loadace command, the SystemAce control register is left in a wonky state. */ /* this code did not work in board_pre_init */
@@ -115,17 +115,19 @@ int checkboard (void)puts ("Serial#: " ); -if (!s) { +if (l <0 ) {printf ("### No HW ID - assuming AMIRIX" ); }else { -for (e = s; *e; ++e) { -if (*e ==' ' ) +int i; + +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' ) { + buf[i] ='\0' ;break ; + } } -for (; s < e; ++s) { -putc (*s); - } +puts (buf); }putc ('\n' );
@@ -136,9 +138,11 @@ int checkboard (void)phys_size_t initdram (int board_type) { -char *s =getenv ("dramsize" ); +char buf[64 ]; +int i =getenv_f ("dramsize" , buf,sizeof (buf)); -if (s !=NULL ) { +if (i >0 ) { +char *s = buf;if ((s[0 ] =='0' ) && ((s[1 ] =='x' ) || (s[1 ] =='X' ))) { s +=2 ; }
board/avnet/fx12mm/fx12mm.c +8 -9
@@ -32,20 +32,19 @@int checkboard (void ) { -char tmp[64 ]; -char *s, *e; -int i =getenv_f ("serial" , tmp,sizeof (tmp)); +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf)); -if (i <0 ) { +if (l <0 ) {printf ("Avnet Virtex4 FX12 with no serial #" ); }else { -for (e = tmp; *e; ++e) { -if (*e ==' ' ) +printf ("Avnet Virtex4 FX12 Minimodul # " ); +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; +putc (buf[i]); } -printf ("Avnet Virtex4 FX12 Minimodul # " ); -for (s = tmp; s < e; ++s) -putc (*s); }putc ('\n' );return 0 ;
board/c2mon/c2mon.c +6 -4
@@ -91,14 +91,16 @@ const uint sdram_table[] =int checkboard (void ) { -unsigned char *s = (unsigned char *)getenv ("serial#" ); +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: TTTech C2MON " ); -for (; s && *s; ++s) { -if (*s ==' ' ) +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; -putc (*s); +putc (buf[i]); }putc ('\n' );
board/digsy_mtc/digsy_mtc.c +5 -4
@@ -191,15 +191,16 @@ phys_size_t initdram(int board_type)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: InterControl digsyMTC" );#if defined(CONFIG_DIGSY_REV5 )puts (" rev5" );#endif -if (s !=NULL ) { -puts (", " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
board/etx094/etx094.c +7 -9
@@ -92,8 +92,9 @@ const uint sdram_table[] = {int checkboard (void ) { -char *s =getenv ("serial#" ); -char *e; +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: " );
@@ -103,19 +104,16 @@ int checkboard (void) gd->board_type =1 ;/* 1 = 1SDRAM-Device */ #endif -if (!s ||strncmp (s,"ETX_" ,4 )) { +if (l <0 ||strncmp (buf,"ETX_" ,4 )) {puts ("### No HW ID - assuming ETX_094\n" );read_hw_vers ();return (0 ); } -for (e = s; *e; ++e) { -if (*e ==' ' ) +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; - } - -for (; s < e; ++s) { -putc (*s); +putc (buf[i]); }putc ('\n' );
board/gdsys/405ep/dlvision-10g.c +4 -3
@@ -225,15 +225,16 @@ static void print_fpga_info(unsigned dev)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: " );printf ("DLVision 10G" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }puts ("\n" );
board/gdsys/405ep/io.c +4 -3
@@ -87,8 +87,9 @@ err_out:*/ int checkboard (void ) { +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));ihs_fpga_t *fpga = (ihs_fpga_t *)CONFIG_SYS_FPGA_BASE (0 ); -char *s =getenv ("serial#" );u16 versions =in_le16 (&fpga->versions);u16 fpga_version =in_le16 (&fpga->fpga_version);u16 fpga_features =in_le16 (&fpga->fpga_features);
@@ -106,9 +107,9 @@ int checkboard(void)printf ("CATCenter Io" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }puts ("\n " );
board/gdsys/405ep/iocon.c +4 -3
@@ -69,8 +69,9 @@ enum {*/ int checkboard (void ) { +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));ihs_fpga_t *fpga = (ihs_fpga_t *)CONFIG_SYS_FPGA_BASE (0 ); -char *s =getenv ("serial#" );u16 versions =in_le16 (&fpga->versions);u16 fpga_version =in_le16 (&fpga->fpga_version);u16 fpga_features =in_le16 (&fpga->fpga_features);
@@ -98,9 +99,9 @@ int checkboard(void)printf ("IoCon" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }puts ("\n " );
board/gdsys/dlvision/dlvision.c +4 -3
@@ -75,7 +75,8 @@ int misc_init_r(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));u8 channel2_msr =in_8 ((void *)CONFIG_UART_BASE +0x26 );u8 channel3_msr =in_8 ((void *)CONFIG_UART_BASE +0x36 );u8 channel7_msr =in_8 ((void *)CONFIG_UART_BASE +0x76 );
@@ -108,9 +109,9 @@ int checkboard(void)break ; } -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }puts ("\n " );
board/gdsys/gdppc440etx/gdppc440etx.c +4 -3
@@ -145,13 +145,14 @@ int misc_init_r(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: GDPPC440ETX - G&D PPC440EP/GR ETX-module" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/gdsys/intip/intip.c +4 -3
@@ -124,7 +124,8 @@ int get_cpu_num(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));#ifdef CONFIG_DEVCONCENTER printf ("Board: DevCon-Center" );
@@ -132,9 +133,9 @@ int checkboard(void)printf ("Board: Intip" );#endif -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/gdsys/neo/neo.c +4 -3
@@ -53,7 +53,8 @@ int board_early_init_f(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));u16 val =in_le16 ((void *)CONFIG_FPGA_BASE +2 );u8 unit_type;u8 hardware_cpu_ports;
@@ -62,9 +63,9 @@ int checkboard(void)printf ("Board: CATCenter Neo" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }puts ("\n " );
board/gw8260/gw8260.c +4 -4
@@ -214,13 +214,13 @@ const iop_conf_t iop_conf_tab[4][32] = {/*********************************************************************/ int checkboard (void ) { -char *str; +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: Advent Networks gw8260\n" ); - str =getenv ("serial#" ); -if (str !=NULL ) { -printf ("SN: %s\n" , str); +if (i >0 ) { +printf ("SN: %s\n" , buf); }return 0 ; }
board/hermes/hermes.c +7 -9
@@ -107,21 +107,19 @@ const uint sdram_table[] = {int checkboard (void ) { -char *s =getenv ("serial#" ); -char *e; +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: " ); -if (!s ||strncmp (s,"HERMES" ,6 )) { +if (l <0 ||strncmp (buf,"HERMES" ,6 )) {puts ("### No HW ID - assuming HERMES-PRO" ); }else { -for (e = s; *e; ++e) { -if (*e ==' ' ) +for (i =0 ; i < l; i++) { +if (buf[i] ==' ' )break ; - } - -for (; s < e; ++s) { -putc (*s); +putc (buf[i]); } }
board/ixdp425/ixdp425.c +4 -3
@@ -83,7 +83,8 @@ int board_init (void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));#ifdef CONFIG_IXDPG425 puts ("Board: IXDPG425 - Intel Network Gateway Reference Platform" );
@@ -91,9 +92,9 @@ int checkboard(void)puts ("Board: IXDP425 - Intel Development Platform" );#endif -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/lwmon5/lwmon5.c +4 -3
@@ -333,13 +333,14 @@ int misc_init_r(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: lwmon5" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/micronas/vct/vct.c +4 -3
@@ -80,8 +80,9 @@ phys_size_t initdram(int board_type)int checkboard (void ) { +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));u32 config0 =read_c0_prid (); -char *s =getenv ("serial#" );if ((config0 &0xff0000 ) ==PRID_COMP_LEGACY && (config0 &0xff00 ) ==PRID_IMP_LX4280 ) {
@@ -108,9 +109,9 @@ int checkboard(void) }printf ("Board: Micronas VCT " BOARD_NAME BOARD_NAME_ADD ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/ml2/ml2.c +7 -11
@@ -30,23 +30,19 @@ int board_early_init_f (void)int checkboard (void ) { -char *s =getenv ("serial#" ); -char *e; +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf)); -if (!s ||strncmp (s,"ML2" ,9 )) { +if (l <0 ||strncmp (buf,"ML2" ,9 )) {printf ("### No HW ID - assuming ML2" ); }else { -for (e = s; *e; ++e) { -if (*e ==' ' ) +for (i =0 ; i < l; i++) { +if (buf[i] ==' ' )break ; - } - -for (; s < e; ++s) { -putc (*s); +putc (buf[i]); } } - -putc ('\n' );return (0 );
board/mosaixtech/icon/icon.c +4 -3
@@ -275,12 +275,13 @@ int board_early_init_r(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: ICON" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/pcs440ep/pcs440ep.c +4 -3
@@ -509,12 +509,13 @@ int misc_init_r (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: PCS440EP" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/prodrive/alpr/alpr.c +5 -4
@@ -133,12 +133,13 @@ static int board_rev(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: ALPR" ); -if (s !=NULL ) { -puts (", serial# " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }printf (" (Rev. %d)\n" ,board_rev ());
board/prodrive/p3mx/p3mx.c +4 -3
@@ -335,13 +335,14 @@ void after_reloc (ulong dest_addr, gd_t * gd)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: %s" ,CONFIG_SYS_BOARD_NAME ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/prodrive/p3p440/p3p440.c +4 -3
@@ -122,12 +122,13 @@ int board_early_init_f(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: P3P440" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }if (is_monarch ()) {
board/prodrive/pdnb3/pdnb3.c +4 -3
@@ -101,13 +101,14 @@ int board_init(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: PDNB3" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/quad100hd/quad100hd.c +4 -3
@@ -58,16 +58,17 @@ int board_early_init_f(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));#ifdef DISPLAY_BOARD_INFO sys_info_t sysinfo;#endif puts ("Board: Quad100hd" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/quantum/quantum.c +6 -4
@@ -87,14 +87,16 @@ const uint sdram_table[] = {int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board QUANTUM, Serial No: " ); -for (; s && *s; ++s) { -if (*s ==' ' ) +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; -putc (*s); +putc (buf[i]); }putc ('\n' );return (0 );/* success */
board/rbc823/rbc823.c +5 -4
@@ -127,15 +127,16 @@ const uint static_table[] =int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf)); -if (!s ||strncmp (s,"TQM8" ,4 )) { +if (i <0 ||strncmp (buf,"TQM8" ,4 )) {printf ("### No HW ID - assuming RBC823\n" );return (0 ); } -puts (s); -putc ('\n' ); +puts (buf); +putc ('\n' );return (0 ); }
board/socrates/socrates.c +7 -5
@@ -52,15 +52,17 @@ ulong flash_get_size (ulong base, int banknum);int checkboard (void ) {volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); - -char *src; +char buf[64 ];int f; -char *s =getenv ("serial#" ); +int i =getenv_f ("serial#" , buf,sizeof (buf)); +#ifdef CONFIG_PCI +char *src; +#endif puts ("Board: Socrates" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/svm_sc8xx/svm_sc8xx.c +17 -15
@@ -75,27 +75,29 @@ const uint sdram_table[] =* Return 1 for "SC8xx" type, 0 else. */ -int checkboard (void ) +int checkboard (void ) { -char *s =getenv ("serial#" ); -int board_type; +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf)); +int board_type; -if (!s ||strncmp (s,"SVM8" ,4 )) { -printf ("### No HW ID - assuming SVM SC8xx\n" ); -return (0 ); - } +if (l <0 ||strncmp (buf,"SVM8" ,4 )) { +printf ("### No HW ID - assuming SVM SC8xx\n" ); +return (0 ); + } - board_type =1 ; + board_type =1 ; -for (; *s; ++s) { -if (*s ==' ' ) -break ; -putc (*s); - } +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' ) +break ; +putc (buf[i]); + } -putc ('\n' ); +putc ('\n' ); -return (0 ); +return (0 ); }/* ------------------------------------------------------------------------- */
board/t3corp/t3corp.c +4 -3
@@ -89,13 +89,14 @@ int board_early_init_f(void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: T3CORP" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/ti/omap5912osk/omap5912osk.c +4 -3
@@ -295,13 +295,14 @@ void peripheral_power_enable (void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: OSK5912" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
board/tqc/tqm8260/tqm8260.c +4 -4
@@ -195,17 +195,17 @@ const iop_conf_t iop_conf_tab[4][32] = {*/ int checkboard (void ) { -char str[64 ]; -int i =getenv_f ("serial#" , str,sizeof (str)); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: " ); -if (!i ||strncmp (str,"TQM82" ,5 )) { +if (i <0 ||strncmp (buf,"TQM82" ,5 )) {puts ("### No HW ID - assuming TQM8260\n" );return (0 ); } -puts (str); +puts (buf);putc ('\n' );return 0 ;
board/tqc/tqm8272/tqm8272.c +6 -2
@@ -514,12 +514,16 @@ static inline int scanChar (char *p, int len, unsigned long *number)static int dump_hwib (void ) {HWIB_INFO *hw = &hwinf; +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR ; -char *s =getenv ("serial#" ); + +if (i <0 ) + buf[0 ] ='\0' ;if (hw->OK) {printf ("HWIB on %x\n" ,HWIB_INFO_START_ADDR ); -printf ("serial : %s\n" , s); +printf ("serial : %s\n" , buf);printf ("ethaddr: %s\n" , hw->ethaddr);printf ("FLASH : %x nr:%d\n" , hw->flash, hw->flash_nr);printf ("RAM : %x cs:%d\n" , hw->ram, hw->ram_cs);
board/tqc/tqm85xx/tqm85xx.c +11 -8
@@ -227,17 +227,19 @@ static const int casl_table[] = { 20, 25, 30 };int cas_latency (void ) { -char *s =getenv ("serial#" ); +char buf[128 ];int casl;int val;int i; casl =CONFIG_DDR_DEFAULT_CL ; -if (s !=NULL ) { -if (strncmp (s +strlen (s) -strlen (CASL_STRING1 ), + i =getenv_f ("serial#" , buf,sizeof (buf)); + +if (i >0 ) { +if (strncmp (buf +strlen (buf) -strlen (CASL_STRING1 ),CASL_STRING2 ,strlen (CASL_STRING2 )) ==0 ) { - val =simple_strtoul (s +strlen (s) -2 ,NULL ,10 ); + val =simple_strtoul (buf +strlen (buf) -2 ,NULL ,10 );for (i =0 ; i <N_CASL ; ++i) {if (val == casl_table[i]) {
@@ -252,12 +254,13 @@ int cas_latency (void)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));printf ("Board: %s" ,CONFIG_BOARDNAME ); -if (s !=NULL ) { -puts (", serial# " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
board/tqc/tqm8xx/tqm8xx.c +10 -8
@@ -106,31 +106,33 @@ const uint sdram_table[] =int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: " ); -if (!s ||strncmp (s,"TQM8" ,4 )) { +if (l <0 ||strncmp (buf,"TQM8" ,4 )) {puts ("### No HW ID - assuming TQM8xxL\n" );return (0 ); } -if ((*(s +6 ) =='L' )) {/* a TQM8xxL type */ +if ((buf[6 ] =='L' )) {/* a TQM8xxL type */ gd->board_type ='L' ; } -if ((*(s +6 ) =='M' )) {/* a TQM8xxM type */ +if ((buf[6 ] =='M' )) {/* a TQM8xxM type */ gd->board_type ='M' ; } -if ((*(s +6 ) =='D' )) {/* a TQM885D type */ +if ((buf[6 ] =='D' )) {/* a TQM885D type */ gd->board_type ='D' ; } -for (; *s; ++s) { -if (*s ==' ' ) +for (i =0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; -putc (*s); +putc (buf[i]); }#ifdef CONFIG_VIRTLAB2 puts (" (Virtlab2)" );
board/xes/common/board.c +11 -6
@@ -13,7 +13,9 @@int checkboard (void ) {char name[] =CONFIG_SYS_BOARD_NAME ; +char buf[64 ];char *s; +int i;#ifdef CONFIG_SYS_FORM_CUSTOM s ="Custom" ;
@@ -52,12 +54,15 @@ int checkboard(void)/* Display board specific information */ puts (" " ); -if ((s =getenv ("board_rev" ))) -printf ("Rev %s, " , s); -if ((s =getenv ("serial#" ))) -printf ("Serial# %s, " , s); -if ((s =getenv ("board_cfg" ))) -printf ("Cfg %s" , s); + i =getenv_f ("board_rev" , buf,sizeof (buf)); +if (i >0 ) +printf ("Rev %s, " , buf); + i =getenv_f ("serial#" , buf,sizeof (buf)); +if (i >0 ) +printf ("Serial# %s, " , buf); + i =getenv_f ("board_cfg" , buf,sizeof (buf)); +if (i >0 ) +printf ("Cfg %s" , buf);puts ("\n" );return 0 ;
board/xes/xpedite1000/xpedite1000.c +11 -10
@@ -112,19 +112,20 @@ int board_early_init_f(void)int checkboard (void ) { -char *s; +char buf[64 ]; +int i;printf ("Board: X-ES %s PMC SBC\n" ,CONFIG_SYS_BOARD_NAME );printf (" " ); - s =getenv ("board_rev" ); -if (s) -printf ("Rev %s, " , s); - s =getenv ("serial#" ); -if (s) -printf ("Serial# %s, " , s); - s =getenv ("board_cfg" ); -if (s) -printf ("Cfg %s" , s); + i =getenv_f ("board_rev" , buf,sizeof (buf)); +if (i >0 ) +printf ("Rev %s, " , buf); + i =getenv_f ("serial#" , buf,sizeof (buf)); +if (i >0 ) +printf ("Serial# %s, " , buf); + i =getenv_f ("board_cfg" , buf,sizeof (buf)); +if (i >0 ) +printf ("Cfg %s" , buf);printf ("\n" );return 0 ;
board/zeus/zeus.c +4 -3
@@ -161,7 +161,8 @@ int misc_init_r(void)*/ int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: Zeus-" );
@@ -172,9 +173,9 @@ int checkboard(void)puts (" of BulletEndPoint" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
Signature · 1 line
1.7.4.4
PATCH 1/1 Fix incorrect use of getenv() before relocation
Hi Wolfgang,
Quoted 80 lines
A large number of boards incorrectly used
getenv()in their board init code running before relocation. In some cases this caused U-Boot to hang when certain environment variables grew too long.
Fix the code to usegetenv_r().Signed-off-by Wolfgang Denk <[email protected]>Cc Stefan Roese <[email protected]>Cc The LEOX team <[email protected]>Cc Michael Schwingen <[email protected]>Cc Georg Schardt <[email protected]>Cc Werner Pfister <[email protected]>Cc Dirk Eibach <[email protected]>Cc Peter De Schrijver <[email protected]>Cc John Zhan <[email protected]>Cc Rishi Bhattacharya <[email protected]>Cc Peter Tyser <[email protected]>--- board/LEOX/elpt860/elpt860.c | 5 +++-- board/RRvision/RRvision.c | 10 ++++++---- board/actux1/actux1.c | 9 +++++---- board/actux2/actux2.c | 9 +++++---- board/actux3/actux3.c | 7 ++++--- board/amcc/acadia/acadia.c | 7 ++++--- board/amcc/bamboo/bamboo.c | 7 ++++--- board/amcc/bluestone/bluestone.c | 7 ++++--- board/amcc/bubinga/bubinga.c | 7 ++++--- board/amcc/canyonlands/canyonlands.c | 7 ++++--- board/amcc/ebony/ebony.c | 7 ++++--- board/amcc/katmai/katmai.c | 7 ++++--- board/amcc/kilauea/kilauea.c | 7 ++++--- board/amcc/luan/luan.c | 7 ++++--- board/amcc/makalu/makalu.c | 7 ++++--- board/amcc/ocotea/ocotea.c | 9 +++++---- board/amcc/redwood/redwood.c | 7 ++++--- board/amcc/sequoia/sequoia.c | 7 ++++--- board/amcc/taihu/taihu.c | 7 ++++--- board/amcc/taishan/taishan.c | 9 +++++---- board/amcc/walnut/walnut.c | 7 ++++--- board/amcc/yosemite/yosemite.c | 7 ++++--- board/amcc/yucca/yucca.c | 7 ++++--- board/amirix/ap1000/ap1000.c | 24 ++++++++++++++---------- board/avnet/fx12mm/fx12mm.c | 17 ++++++++--------- board/c2mon/c2mon.c | 10 ++++++---- board/digsy_mtc/digsy_mtc.c | 9 +++++---- board/etx094/etx094.c | 16 +++++++--------- board/gdsys/405ep/dlvision-10g.c | 7 ++++--- board/gdsys/405ep/io.c | 7 ++++--- board/gdsys/405ep/iocon.c | 7 ++++--- board/gdsys/dlvision/dlvision.c | 7 ++++--- board/gdsys/gdppc440etx/gdppc440etx.c | 7 ++++--- board/gdsys/intip/intip.c | 7 ++++--- board/gdsys/neo/neo.c | 7 ++++--- board/gw8260/gw8260.c | 8 ++++---- board/hermes/hermes.c | 16 +++++++--------- board/ixdp425/ixdp425.c | 7 ++++--- board/lwmon5/lwmon5.c | 7 ++++--- board/micronas/vct/vct.c | 7 ++++--- board/ml2/ml2.c | 18 +++++++----------- board/mosaixtech/icon/icon.c | 7 ++++--- board/pcs440ep/pcs440ep.c | 7 ++++--- board/prodrive/alpr/alpr.c | 9 +++++---- board/prodrive/p3mx/p3mx.c | 7 ++++--- board/prodrive/p3p440/p3p440.c | 7 ++++--- board/prodrive/pdnb3/pdnb3.c | 7 ++++--- board/quad100hd/quad100hd.c | 7 ++++--- board/quantum/quantum.c | 10 ++++++---- board/rbc823/rbc823.c | 9 +++++---- board/socrates/socrates.c | 12 +++++++----- board/svm_sc8xx/svm_sc8xx.c | 32 +++++++++++++++++--------------- board/t3corp/t3corp.c | 7 ++++--- board/ti/omap5912osk/omap5912osk.c | 7 ++++--- board/tqc/tqm8260/tqm8260.c | 8 ++++---- board/tqc/tqm8272/tqm8272.c | 8 ++++++-- board/tqc/tqm85xx/tqm85xx.c | 19 +++++++++++-------- board/tqc/tqm8xx/tqm8xx.c | 18 ++++++++++-------- board/xes/common/board.c | 17 +++++++++++------ board/xes/xpedite1000/xpedite1000.c | 21 +++++++++++---------- board/zeus/zeus.c | 7 ++++--- 61 files changed, 324 insertions(+), 260 deletions(-)
[...]
Quoted 15 lines
board/RRvision/RRvision.c +3
-1@@ -93,14 +93,16 @@ const uint sdram_table[] =int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i; +int l =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: RRvision " );
board/RRvision/RRvision.c const uint sdram_table[] = · line 108
Quoted 10 lines
board/RRvision/RRvision.c +3
-3-for (; s && *s; ++s) { -if (*s ==' ' ) +for (i=0 ; i < l; ++i) { +if (buf[i] ==' ' )break ; -putc (*s); +putc (buf[i]); }putc ('\n' );
Looks good.
[...]
Quoted 14 lines
board/digsy_mtc/digsy_mtc.c +2
-1@@ -191,15 +191,16 @@ phys_size_t initdram(int board_type)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));puts ("Board: InterControl digsyMTC" );#if defined(CONFIG_DIGSY_REV5 )
board/digsy_mtc/digsy_mtc.c phys_size_t initdram(int board_type) · line 205
Quoted 10 lines
board/digsy_mtc/digsy_mtc.c +3
-3puts (" rev5" );#endif -if (s !=NULL ) { -puts (", " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );
This changes the output. On the other hand, this feature was never used on this board, so I'm ok with removing this read altogether.
[...]
Quoted 17 lines
board/socrates/socrates.c +5
-3@@ -52,15 +52,17 @@ ulong flash_get_size (ulong base, int banknum);int checkboard (void ) {volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); - -char *src; +char buf[64 ];int f; -char *s =getenv ("serial#" ); +int i =getenv_f ("serial#" , buf,sizeof (buf)); +#ifdef CONFIG_PCI +char *src; +#endif
board/socrates/socrates.c ulong flash_get_size (ulong base, int banknum); · line 68
Quoted 10 lines
board/socrates/socrates.c +2
-2puts ("Board: Socrates" ); -if (s !=NULL ) { +if (i >0 ) {puts (", serial# " ); -puts (s); +puts (buf); }putc ('\n' );
Looks good.
Cheers
Detlev
Signature · 7 lines
Another helpful hint for successful MIME processing: application/msword; rm -f %s; description="MS Word Text"; -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
PATCH 1/1 Fix incorrect use of getenv() before relocation
Dear Detlev Zundel,
Quoted 1 line · In message <[email protected]> you wrote:
...
Quoted 11 lines
Quoted 11 lines
index 9f13a3d..a0c4b10 100644
board/digsy_mtc/digsy_mtc.c +2
-1@@ -191,15 +191,16 @@ phys_size_t initdram(int board_type)int checkboard (void ) { -char *s =getenv ("serial#" ); +char buf[64 ]; +int i =getenv_f ("serial#" , buf,sizeof (buf));
Quoted 15 lines
board/digsy_mtc/digsy_mtc.c phys_size_t initdram(int board_type) · line 205
Quoted 12 lines
board/digsy_mtc/digsy_mtc.c +3
-3puts ("Board: InterControl digsyMTC" );#if defined(CONFIG_DIGSY_REV5 )puts (" rev5" );#endif -if (s !=NULL ) { -puts (", " ); -puts (s); +if (i >0 ) { +puts (", serial# " ); +puts (buf); }putc ('\n' );This changes the output. On the other hand, this feature was never used on this board, so I'm ok with removing this read altogether.
You are right, this should be:
+ if (i > 0) {
+ puts(", ");
+ puts(buf);
What do you mean by "removing this read" ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de CAUTION: The Mass of This Product Contains the Energy Equivalent of 85 Million Tons of TNT per Net Ounce of Weight.
PATCH 1/1 Fix incorrect use of getenv() before relocation
In reply to Wolfgang DenkDear Wolfgang Denk,
Quoted 71 lines · In message <[email protected]> you wrote:
A large number of boards incorrectly used
getenv()in their board init code running before relocation. In some cases this caused U-Boot to hang when certain environment variables grew too long.
Fix the code to usegetenv_r().Signed-off-by Wolfgang Denk <[email protected]>Cc Stefan Roese <[email protected]>Cc The LEOX team <[email protected]>Cc Michael Schwingen <[email protected]>Cc Georg Schardt <[email protected]>Cc Werner Pfister <[email protected]>Cc Dirk Eibach <[email protected]>Cc Peter De Schrijver <[email protected]>Cc John Zhan <[email protected]>Cc Rishi Bhattacharya <[email protected]>Cc Peter Tyser <[email protected]>--- board/LEOX/elpt860/elpt860.c | 5 +++-- board/RRvision/RRvision.c | 10 ++++++---- board/actux1/actux1.c | 9 +++++---- board/actux2/actux2.c | 9 +++++---- board/actux3/actux3.c | 7 ++++--- board/amcc/acadia/acadia.c | 7 ++++--- board/amcc/bamboo/bamboo.c | 7 ++++--- board/amcc/bluestone/bluestone.c | 7 ++++--- board/amcc/bubinga/bubinga.c | 7 ++++--- board/amcc/canyonlands/canyonlands.c | 7 ++++--- board/amcc/ebony/ebony.c | 7 ++++--- board/amcc/katmai/katmai.c | 7 ++++--- board/amcc/kilauea/kilauea.c | 7 ++++--- board/amcc/luan/luan.c | 7 ++++--- board/amcc/makalu/makalu.c | 7 ++++--- board/amcc/ocotea/ocotea.c | 9 +++++---- board/amcc/redwood/redwood.c | 7 ++++--- board/amcc/sequoia/sequoia.c | 7 ++++--- board/amcc/taihu/taihu.c | 7 ++++--- board/amcc/taishan/taishan.c | 9 +++++---- board/amcc/walnut/walnut.c | 7 ++++--- board/amcc/yosemite/yosemite.c | 7 ++++--- board/amcc/yucca/yucca.c | 7 ++++--- board/amirix/ap1000/ap1000.c | 24 ++++++++++++++---------- board/avnet/fx12mm/fx12mm.c | 17 ++++++++--------- board/c2mon/c2mon.c | 10 ++++++---- board/digsy_mtc/digsy_mtc.c | 9 +++++---- board/etx094/etx094.c | 16 +++++++--------- board/gdsys/405ep/dlvision-10g.c | 7 ++++--- board/gdsys/405ep/io.c | 7 ++++--- board/gdsys/405ep/iocon.c | 7 ++++--- board/gdsys/dlvision/dlvision.c | 7 ++++--- board/gdsys/gdppc440etx/gdppc440etx.c | 7 ++++--- board/gdsys/intip/intip.c | 7 ++++--- board/gdsys/neo/neo.c | 7 ++++--- board/gw8260/gw8260.c | 8 ++++---- board/hermes/hermes.c | 16 +++++++--------- board/ixdp425/ixdp425.c | 7 ++++--- board/lwmon5/lwmon5.c | 7 ++++--- board/micronas/vct/vct.c | 7 ++++--- board/ml2/ml2.c | 18 +++++++----------- board/mosaixtech/icon/icon.c | 7 ++++--- board/pcs440ep/pcs440ep.c | 7 ++++--- board/prodrive/alpr/alpr.c | 9 +++++---- board/prodrive/p3mx/p3mx.c | 7 ++++--- board/prodrive/p3p440/p3p440.c | 7 ++++--- board/prodrive/pdnb3/pdnb3.c | 7 ++++--- board/quad100hd/quad100hd.c | 7 ++++--- board/quantum/quantum.c | 10 ++++++---- board/rbc823/rbc823.c | 9 +++++---- board/socrates/socrates.c | 12 +++++++----- board/svm_sc8xx/svm_sc8xx.c | 32 +++++++++++++++++--------------- board/t3corp/t3corp.c | 7 ++++--- board/ti/omap5912osk/omap5912osk.c | 7 ++++---
Quoted 8 lines
board/tqc/tqm8260/tqm8260.c | 8 ++++---- board/tqc/tqm8272/tqm8272.c | 8 ++++++-- board/tqc/tqm85xx/tqm85xx.c | 19 +++++++++++-------- board/tqc/tqm8xx/tqm8xx.c | 18 ++++++++++-------- board/xes/common/board.c | 17 +++++++++++------ board/xes/xpedite1000/xpedite1000.c | 21 +++++++++++---------- board/zeus/zeus.c | 7 ++++--- 61 files changed, 324 insertions(+), 260 deletions(-)
Applied (with fix for board/digsy_mtc/digsy_mtc.c as pointed out by Detlev).
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In the beginning, there was nothing, which exploded.
- Terry Pratchett, _Lords and Ladies_