[U-Boot] [RFC 0/2] Remove CONFIG_SYS_MAXARGS

John Schmoller jschmoller at xes-inc.com
Fri Mar 12 16:51:46 CET 2010


The first patch removes CONFIG_SYS_MAXARGS, replacing the staticly defined
array with a malloc'd array of the appropriate size. When a function has no
upper argument limit (ie, was set to CONFIG_SYS_MAXARGS), it is now set to 0
to indicate this fact.  Argument count is now unlimited, within reason and
malloc buffer size.

The second patch removes cmdtp->maxargs and moves the checks to the individual
command functions.  Since most functions do bounds checking anyway, it's a
a fairly cheap task (sometimes free) to remove this bounds check in
common/main.c.  In addition, it's more intuitive (in my opinion) if all bounds
checking is done in only one place for each function.  The second patch also
creates a CMD_ERR_USAGE return value, which prints usage when returned.  The
overall effect of this patch is to reduce code size by an average of 200-250
bytes and, I feel, make things a bit cleaner.

I'm looking for comments on these two patches as they are quite invasive, and
will definitly cause problems for those people who maintain their own code
out-of-tree.  They may also require an additional amount of testing.

John Schmoller (2):
  cmd: Remove CONFIG_SYS_MAXARGS
  command: Remove maxargs from command structure

 board/BuS/EB+MCF-EV123/EB+MCF-EV123.c         |    8 +-
 board/BuS/eb_cpux9k2/cpux9k2.c                |    5 +-
 board/MAI/AmigaOneG3SE/cmd_boota.c            |    6 +-
 board/MAI/menu/cmd_menu.c                     |    6 +-
 board/amcc/acadia/cmd_acadia.c                |    8 +-
 board/amcc/luan/luan.c                        |    5 +-
 board/amcc/makalu/cmd_pll.c                   |   11 +--
 board/amcc/taihu/lcd.c                        |   31 +++---
 board/amcc/taihu/taihu.c                      |   22 ++---
 board/amcc/taihu/update.c                     |    5 +-
 board/amcc/taishan/lcd.c                      |   48 ++++++----
 board/amcc/taishan/showinfo.c                 |   15 +++-
 board/amcc/taishan/update.c                   |    5 +-
 board/amcc/yucca/cmd_yucca.c                  |    8 +-
 board/amirix/ap1000/ap1000.c                  |   21 +++-
 board/amirix/ap1000/powerspan.c               |    4 +-
 board/barco/barco.c                           |   15 +--
 board/bc3450/cmd_bc3450.c                     |   44 +++++----
 board/bf537-stamp/cmd_bf537led.c              |    2 +-
 board/cm-bf527/gpio.c                         |    5 +-
 board/cm-bf537e/flash.c                       |    5 +-
 board/cm-bf537u/flash.c                       |    5 +-
 board/cm5200/cmd_cm5200.c                     |    2 +-
 board/delta/delta.c                           |    5 +-
 board/digsy_mtc/cmd_mtc.c                     |   48 ++++-----
 board/esd/ar405/ar405.c                       |   20 +++--
 board/esd/cms700/cms700.c                     |    5 +-
 board/esd/common/auto_update.c                |    5 +-
 board/esd/common/cmd_loadpci.c                |    5 +-
 board/esd/common/lcd.c                        |    8 +-
 board/esd/common/xilinx_jtag/micro.c          |    8 +-
 board/esd/cpci2dp/cpci2dp.c                   |    5 +-
 board/esd/cpci405/cpci405.c                   |   14 ++-
 board/esd/cpci5200/cpci5200.c                 |    5 +-
 board/esd/cpci750/cpci750.c                   |   10 ++-
 board/esd/dasa_sim/cmd_dasa_sim.c             |    8 +-
 board/esd/du440/du440.c                       |   34 +++++--
 board/esd/hh405/hh405.c                       |    5 +-
 board/esd/ocrtc/cmd_ocrtc.c                   |   10 ++-
 board/esd/pci405/cmd_pci405.c                 |    5 +-
 board/esd/pci405/pci405.c                     |    8 +-
 board/esd/pf5200/pf5200.c                     |   15 +++-
 board/esd/plu405/plu405.c                     |    5 +-
 board/esd/pmc405de/pmc405de.c                 |   21 +++-
 board/esd/pmc440/cmd_pmc440.c                 |   58 +++++++-----
 board/esd/tasreg/tasreg.c                     |   45 ++++-----
 board/esd/vme8349/caddy.c                     |    8 +-
 board/esd/voh405/voh405.c                     |    5 +-
 board/evb64260/zuma_pbb.c                     |   15 +++-
 board/fads/fads.h                             |    1 -
 board/freescale/common/pixis.c                |    9 +-
 board/freescale/common/sys_eeprom.c           |    9 +-
 board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c |    8 +-
 board/g2000/g2000.c                           |   15 +++-
 board/hymod/bsp.c                             |   10 +-
 board/inka4x0/inkadiag.c                      |   31 +++---
 board/keymile/common/keymile_hdlc_enet.c      |   10 ++-
 board/keymile/km_arm/km_arm.c                 |   11 +--
 board/lwmon/lwmon.c                           |   15 ++--
 board/lwmon5/kbd.c                            |    5 +-
 board/lwmon5/lwmon5.c                         |   11 +--
 board/micronas/vct/smc_eeprom.c               |   15 +++-
 board/mpl/common/common_util.c                |    3 +-
 board/mpl/mip405/cmd_mip405.c                 |    5 +-
 board/mpl/pati/cmd_pati.c                     |    5 +-
 board/mpl/pip405/cmd_pip405.c                 |    5 +-
 board/mpl/vcma9/cmd_vcma9.c                   |    6 +-
 board/pcippc2/pcippc2.c                       |    5 +-
 board/pcs440ep/pcs440ep.c                     |   12 ++-
 board/pn62/cmd_pn62.c                         |   14 +--
 board/prodrive/pdnb3/pdnb3.c                  |    8 +-
 board/pxa255_idp/pxa_idp.c                    |    2 +-
 board/r360mpi/r360mpi.c                       |    5 +-
 board/renesas/sh7785lcr/rtl8169_mac.c         |   16 +--
 board/renesas/sh7785lcr/selfcheck.c           |   11 +--
 board/renesas/sh7785lcr/sh7785lcr.c           |    5 +-
 board/sandburst/common/ppc440gx_i2c.c         |    5 +-
 board/sandburst/karef/karef.c                 |   10 ++-
 board/sandburst/metrobox/metrobox.c           |   10 ++-
 board/siemens/common/fpga.c                   |    7 +-
 board/siemens/pcu_e/pcu_e.c                   |    5 +-
 board/spear/common/spr_misc.c                 |   11 +--
 board/ssv/common/cmd_sled.c                   |    5 +-
 board/ssv/common/wd_pio.c                     |    5 +-
 board/tcm-bf537/flash.c                       |    5 +-
 board/tqc/tqm5200/cmd_stk52xx.c               |   38 +++-----
 board/tqc/tqm5200/cmd_tb5200.c                |   16 ++-
 board/tqc/tqm8272/tqm8272.c                   |    5 +-
 board/trab/cmd_trab.c                         |   48 ++++------
 board/trab/trab.c                             |    5 +-
 board/trizepsiv/eeprom.c                      |   20 ++---
 board/w7o/cmd_vpd.c                           |    8 +-
 board/zeus/update.c                           |    6 +-
 board/zeus/zeus.c                             |   13 ++-
 common/cmd_ambapp.c                           |    5 +-
 common/cmd_bdinfo.c                           |   30 ++++++-
 common/cmd_bedbug.c                           |   46 ++++++---
 common/cmd_bmp.c                              |    8 +-
 common/cmd_boot.c                             |   10 +-
 common/cmd_bootldr.c                          |    5 +-
 common/cmd_bootm.c                            |   38 ++++---
 common/cmd_cache.c                            |   18 ++--
 common/cmd_console.c                          |    5 +-
 common/cmd_cplbinfo.c                         |    5 +-
 common/cmd_cramfs.c                           |   12 ++-
 common/cmd_dataflash_mmc_mux.c                |    2 +-
 common/cmd_date.c                             |    5 +-
 common/cmd_dcr.c                              |   32 +++----
 common/cmd_df.c                               |    7 +-
 common/cmd_diag.c                             |    2 +-
 common/cmd_display.c                          |    2 +-
 common/cmd_dtt.c                              |    5 +-
 common/cmd_echo.c                             |    2 +-
 common/cmd_eeprom.c                           |    7 +-
 common/cmd_elf.c                              |   18 +++-
 common/cmd_exit.c                             |    5 +-
 common/cmd_ext2.c                             |   14 +--
 common/cmd_fat.c                              |   27 +++---
 common/cmd_fdc.c                              |    5 +-
 common/cmd_fdos.c                             |    9 +-
 common/cmd_fdt.c                              |   38 +++-----
 common/cmd_flash.c                            |   49 ++++------
 common/cmd_fpga.c                             |   13 +--
 common/cmd_help.c                             |    4 +-
 common/cmd_i2c.c                              |   76 ++++++---------
 common/cmd_ide.c                              |   25 ++---
 common/cmd_immap.c                            |   51 +++++++---
 common/cmd_irq.c                              |   10 +-
 common/cmd_itest.c                            |    8 +-
 common/cmd_jffs2.c                            |   15 +++-
 common/cmd_license.c                          |    5 +-
 common/cmd_load.c                             |   34 +++++--
 common/cmd_log.c                              |    8 +-
 common/cmd_mac.c                              |    2 +-
 common/cmd_mem.c                              |  120 +++++++++--------------
 common/cmd_mfsl.c                             |   34 +++----
 common/cmd_mgdisk.c                           |    2 +-
 common/cmd_mii.c                              |   11 +--
 common/cmd_misc.c                             |    8 +-
 common/cmd_mmc.c                              |   38 +++-----
 common/cmd_mp.c                               |   17 +--
 common/cmd_mtdparts.c                         |   13 ++-
 common/cmd_nand.c                             |   10 +-
 common/cmd_net.c                              |   45 +++++----
 common/cmd_nvedit.c                           |   37 +++----
 common/cmd_onenand.c                          |    5 +-
 common/cmd_otp.c                              |    7 +-
 common/cmd_pci.c                              |    8 +-
 common/cmd_pcmcia.c                           |    2 +-
 common/cmd_portio.c                           |   16 +--
 common/cmd_reginfo.c                          |   20 ++++-
 common/cmd_reiser.c                           |   14 +--
 common/cmd_sata.c                             |   20 ++---
 common/cmd_scsi.c                             |   21 ++---
 common/cmd_setexpr.c                          |    8 +-
 common/cmd_sf.c                               |   16 +--
 common/cmd_source.c                           |    5 +-
 common/cmd_spi.c                              |    5 +-
 common/cmd_spibootldr.c                       |    5 +-
 common/cmd_strings.c                          |    8 +-
 common/cmd_terminal.c                         |    6 +-
 common/cmd_test.c                             |    6 +-
 common/cmd_tsi148.c                           |    5 +-
 common/cmd_ubi.c                              |   23 ++---
 common/cmd_ubifs.c                            |   28 +++---
 common/cmd_universe.c                         |    5 +-
 common/cmd_usb.c                              |   12 +--
 common/cmd_version.c                          |    5 +-
 common/cmd_vfd.c                              |    8 +-
 common/cmd_ximg.c                             |    5 +-
 common/cmd_yaffs2.c                           |  130 +++++++++++++++++++------
 common/command.c                              |   37 +------
 common/hush.c                                 |    9 +-
 common/kgdb.c                                 |    2 +-
 common/lcd.c                                  |    5 +-
 common/main.c                                 |   58 +++++++----
 cpu/arm_cortexa8/mx51/clock.c                 |    2 +-
 cpu/arm_cortexa8/omap3/board.c                |    2 +-
 cpu/leon2/interrupts.c                        |    8 ++-
 cpu/leon3/interrupts.c                        |    8 ++-
 cpu/microblaze/interrupts.c                   |    3 +
 cpu/mpc512x/diu.c                             |    8 +-
 cpu/mpc512x/iim.c                             |   11 +--
 cpu/mpc512x/speed.c                           |    5 +-
 cpu/mpc5xx/interrupts.c                       |    3 +
 cpu/mpc5xxx/interrupts.c                      |    7 +-
 cpu/mpc8260/interrupts.c                      |    7 +-
 cpu/mpc83xx/ecc.c                             |   11 +--
 cpu/mpc83xx/speed.c                           |    5 +-
 cpu/nios2/epcs.c                              |    5 +-
 cpu/nios2/interrupts.c                        |    3 +
 cpu/nios2/sysid.c                             |    5 +-
 cpu/ppc4xx/cmd_chip_config.c                  |    5 +-
 cpu/ppc4xx/interrupts.c                       |    3 +
 doc/README.commands                           |    3 +-
 drivers/gpio/pca953x.c                        |   39 +++++---
 drivers/misc/ds4510.c                         |   71 +++++++++-----
 drivers/qe/qe.c                               |   11 +--
 include/command.h                             |   22 +++--
 include/common.h                              |    4 +-
 lib_blackfin/cmd_cache_dump.c                 |   10 ++-
 lib_i386/interrupts.c                         |    3 +
 202 files changed, 1604 insertions(+), 1301 deletions(-)



More information about the U-Boot mailing list