u-boot/board/freescale
Wolfgang Denk 54841ab50c Make sure that argv[] argument pointers are not modified.
The hush shell dynamically allocates (and re-allocates) memory for the
argument strings in the "char *argv[]" argument vector passed to
commands.  Any code that modifies these pointers will cause serious
corruption of the malloc data structures and crash U-Boot, so make
sure the compiler can check that no such modifications are being done
by changing the code into "char * const argv[]".

This modification is the result of debugging a strange crash caused
after adding a new command, which used the following argument
processing code which has been working perfectly fine in all Unix
systems since version 6 - but not so in U-Boot:

int main (int argc, char **argv)
{
	while (--argc > 0 && **++argv == '-') {
/* ====> */	while (*++*argv) {
			switch (**argv) {
			case 'd':
				debug++;
				break;
			...
			default:
				usage ();
			}
		}
	}
	...
}

The line marked "====>" will corrupt the malloc data structures and
usually cause U-Boot to crash when the next command gets executed by
the shell.  With the modification, the compiler will prevent this with
an
	error: increment of read-only location '*argv'

N.B.: The code above can be trivially rewritten like this:

	while (--argc > 0 && **++argv == '-') {
		char *arg = *argv;
		while (*++arg) {
			switch (*arg) {
			...

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-07-04 23:55:42 +02:00
..
common Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
m547xevb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m548xevb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5208evbe m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5235evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5249evb Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
m5253demo m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5253evbe m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5271evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5272c3 m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5275evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5282evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5329evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m5373evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m52277evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m53017evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m54451evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
m54455evb m68k: Move cpu/$CPU to arch/m68k/cpu/$CPU 2010-04-13 09:13:24 +02:00
mpc832xemds mpc83xx: convert all remaining boards over to 83XX_GENERIC_PCI 2009-07-18 19:43:04 -05:00
mpc837xemds ppc: Split MPC83xx SERDES code from MPC85xx/MPC86xx/QorIQ 2010-04-26 22:37:57 -05:00
mpc837xerdb ppc: Split MPC83xx SERDES code from MPC85xx/MPC86xx/QorIQ 2010-04-26 22:37:57 -05:00
mpc5121ads 5xxx, fdt: move fdt_fixup_memory() to cpu.c file 2009-12-08 22:13:02 +01:00
mpc7448hpc2 Move arch/ppc to arch/powerpc 2010-04-21 23:42:38 +02:00
mpc8260ads mpc8260: move FDT memory node fixup into common CPU code. 2009-11-22 23:16:28 +01:00
mpc8266ads rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mpc8313erdb Generic udelay() with watchdog support 2009-12-05 01:08:53 +01:00
mpc8315erdb mpc83xx: Add NAND boot support for MPC8315E-RDB boards 2010-01-07 18:33:52 -06:00
mpc8323erdb rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mpc8349emds mpc83xx: convert all remaining boards over to 83XX_GENERIC_PCI 2009-07-18 19:43:04 -05:00
mpc8349itx Update Freescale copyrights to remove "All Rights Reserved" 2009-07-29 09:59:22 +02:00
mpc8360emds 83xx, uec: split enet_interface in two variables 2010-01-31 22:37:12 -08:00
mpc8360erdk 83xx: Replace CONFIG_ECC_INIT_VIA_DDRC references 2009-07-02 11:15:49 -05:00
mpc8536ds 85xx/fsl-sata: Use is_serdes_configured() to determine if SATA is enabled 2010-05-12 04:53:51 -05:00
mpc8540ads ppc/85xx: Clean up use of LAWAR defines 2009-09-24 12:04:58 -05:00
mpc8541cds 85xx: Move to a common linker script 2009-08-28 17:12:39 -05:00
mpc8544ds fsl: improve the PIXIS code and fix a few bugs 2010-04-07 00:21:27 -05:00
mpc8548cds PCIe, USB: Replace 'end point' references with 'endpoint' 2010-01-17 23:06:44 +01:00
mpc8555cds 85xx: Move to a common linker script 2009-08-28 17:12:39 -05:00
mpc8560ads ppc/85xx: Clean up use of LAWAR defines 2009-09-24 12:04:58 -05:00
mpc8568mds PCIe, USB: Replace 'end point' references with 'endpoint' 2010-01-17 23:06:44 +01:00
mpc8569mds Create CPUDIR variable 2010-04-13 09:12:59 +02:00
mpc8572ds fsl: improve the PIXIS code and fix a few bugs 2010-04-07 00:21:27 -05:00
mpc8610hpcd Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
mpc8641hpcn Move arch/ppc to arch/powerpc 2010-04-21 23:42:38 +02:00
mx31ads arm: Move cpu/$CPU to arch/arm/cpu/$CPU 2010-04-13 09:13:24 +02:00
mx31pdk Convert SMC911X Ethernet driver to CONFIG_NET_MULTI API 2009-07-22 22:53:44 -07:00
mx51evk Add SPI support to mx51evk board 2010-05-05 09:48:41 +02:00
p1_p2_rdb 85xx/p1_p2_rdb: Added RevD board version support 2010-06-29 21:07:26 +02:00
p2020ds p2020ds: add alternate boot bank support using the ngPIXIS FPGA 2010-04-07 00:21:28 -05:00