int i;
        int rcode = 0;
 
+       if (cmd_items > CONFIG_SYS_MAXARGS) {
+               printf("%s: cmd_items %d exceeds hardcoded limit %d."
+                      " Recompile with higher CONFIG_SYS_MAXARGS?\n",
+                      __func__, cmd_items, CONFIG_SYS_MAXARGS);
+               return -1;
+       }
+
        if (argc == 1) {        /*show list of commands */
-               cmd_tbl_t *cmd_array[cmd_items];
+               cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
                int i, j, swaps;
 
                /* Make array of commands from .uboot_cmd section */
 
 #define IAV(i)  bin_at(i), bin_at(i)
 
 static mbinptr av_[NAV * 2 + 2] = {
- 0, 0,
+ NULL, NULL,
  IAV(0),   IAV(1),   IAV(2),   IAV(3),   IAV(4),   IAV(5),   IAV(6),   IAV(7),
  IAV(8),   IAV(9),   IAV(10),  IAV(11),  IAV(12),  IAV(13),  IAV(14),  IAV(15),
  IAV(16),  IAV(17),  IAV(18),  IAV(19),  IAV(20),  IAV(21),  IAV(22),  IAV(23),
   /* check if mem_malloc_init() was run */
   if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
     /* not initialized yet */
-    return 0;
+    return NULL;
   }
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   nb = request2size(bytes);  /* padded request size; */
 
     /* Try to extend */
     malloc_extend_top(nb);
     if ( (remainder_size = chunksize(top) - nb) < (long)MINSIZE)
-      return 0; /* propagate failure */
+      return NULL; /* propagate failure */
   }
 
   victim = top;
   mchunkptr fwd;       /* misc temp for linking */
   int       islr;      /* track whether merging with last_remainder */
 
-  if (mem == 0)                              /* free(0) has no effect */
+  if (mem == NULL)                              /* free(0) has no effect */
     return;
 
   p = mem2chunk(mem);
   if (bytes == 0) { fREe(oldmem); return 0; }
 #endif
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   /* realloc of null is supposed to be same as malloc */
-  if (oldmem == 0) return mALLOc(bytes);
+  if (oldmem == NULL) return mALLOc(bytes);
 
   newp    = oldp    = mem2chunk(oldmem);
   newsize = oldsize = chunksize(oldp);
     }
     else
     {
-      next = 0;
+      next = NULL;
       nextsize = 0;
     }
 
 
       /* try forward + backward first to save a later consolidation */
 
-      if (next != 0)
+      if (next != NULL)
       {
        /* into top */
        if (next == top)
       }
 
       /* backward only */
-      if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
+      if (prev != NULL && (long)(prevsize + newsize) >= (long)nb)
       {
        unlink(prev, bck, fwd);
        newp = prev;
 
     newmem = mALLOc (bytes);
 
-    if (newmem == 0)  /* propagate failure */
-      return 0;
+    if (newmem == NULL)  /* propagate failure */
+      return NULL;
 
     /* Avoid copy if newp is next chunk after oldp. */
     /* (This can only happen when new chunk is sbrk'ed.) */
   mchunkptr remainder;        /* spare room at end to split off */
   long      remainder_size;   /* its size */
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   /* If need less alignment than we give anyway, just relay to malloc */
 
   nb = request2size(bytes);
   m  = (char*)(mALLOc(nb + alignment + MINSIZE));
 
-  if (m == 0) return 0; /* propagate failure */
+  if (m == NULL) return NULL; /* propagate failure */
 
   p = mem2chunk(m);
 
 #endif
   Void_t* mem = mALLOc (sz);
 
-  if ((long)n < 0) return 0;
+  if ((long)n < 0) return NULL;
 
-  if (mem == 0)
-    return 0;
+  if (mem == NULL)
+    return NULL;
   else
   {
     p = mem2chunk(mem);
 #endif
 {
   mchunkptr p;
-  if (mem == 0)
+  if (mem == NULL)
     return 0;
   else
   {
 
 char **global_argv;
 unsigned int global_argc;
 #endif
-unsigned int last_return_code;
-int nesting_level;
+static unsigned int last_return_code;
 #ifndef __U_BOOT__
 extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */
 #endif
         * NAME=VALUE format.  So the first order of business is to
         * split 's' on the '=' into 'name' and 'value' */
        value = strchr(name, '=');
-       if (value==0 && ++value==0) {
+       if (value == NULL && ++value == NULL) {
                free(name);
                return -1;
        }
                        result = -1;
                } else {
                        cur->name = strdup(name);
-                       if(cur->name == 0) {
+                       if (cur->name == NULL) {
                                free(cur);
                                result = -1;
                        } else {
                                struct variables *bottom = top_vars;
                                cur->value = strdup(value);
-                               cur->next = 0;
+                               cur->next = NULL;
                                cur->flg_export = flg_export;
                                cur->flg_read_only = 0;
                                while(bottom->next) bottom=bottom->next;
                        if(strcmp(cur->name, name)==0)
                                break;
                }
-               if(cur!=0) {
+               if (cur != NULL) {
                        struct variables *next = top_vars;
                        if(cur->flg_read_only) {
                                error_msg("%s: readonly variable", name);
 }
 #endif
 
-struct pipe *new_pipe(void) {
+static struct pipe *new_pipe(void)
+{
        struct pipe *pi;
        pi = xmalloc(sizeof(struct pipe));
        pi->num_progs = 0;
 };
 #define NRES (sizeof(reserved_list)/sizeof(struct reserved_combo))
 
-int reserved_word(o_string *dest, struct p_context *ctx)
+static int reserved_word(o_string *dest, struct p_context *ctx)
 {
        struct reserved_combo *r;
        for (r=reserved_list;
 #endif
 
 /* return code is 0 for normal exit, 1 for syntax error */
-int parse_stream(o_string *dest, struct p_context *ctx,
-       struct in_str *input, int end_trigger)
+static int parse_stream(o_string *dest, struct p_context *ctx,
+                       struct in_str *input, int end_trigger)
 {
        unsigned int ch, m;
 #ifndef __U_BOOT__
        return 0;
 }
 
-void mapset(const unsigned char *set, int code)
+static void mapset(const unsigned char *set, int code)
 {
        const unsigned char *s;
        for (s=set; *s; s++) map[*s] = code;
 }
 
-void update_ifs_map(void)
+static void update_ifs_map(void)
 {
        /* char *ifs and char map[256] are both globals. */
        ifs = (uchar *)getenv("IFS");
 
 /* most recursion does not come through here, the exeception is
  * from builtin_source() */
-int parse_stream_outer(struct in_str *inp, int flag)
+static int parse_stream_outer(struct in_str *inp, int flag)
 {
 
        struct p_context ctx;
                top_vars = malloc(sizeof(struct variables));
                top_vars->name = "HUSH_VERSION";
                top_vars->value = "0.01";
-               top_vars->next = 0;
+               top_vars->next = NULL;
                top_vars->flg_export = 0;
                top_vars->flg_read_only = 1;
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
 }
 
 #ifdef __U_BOOT__
-int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_showvar(cmd_tbl_t *cmdtp, int flag, int argc,
+                     char * const argv[])
 {
        int i, k;
        int rcode = 0;
 
 int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 {
        void    *fdt_blob = *of_flat_tree;
-       void    *of_start = 0;
+       void    *of_start = NULL;
        char    *fdt_high;
        ulong   of_len = 0;
        int     err;
                        of_start =
                            (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
                                                           (ulong)desired_addr);
-                       if (of_start == 0) {
+                       if (of_start == NULL) {
                                puts("Failed using fdt_high value for Device Tree");
                                goto error;
                        }
                                                   + getenv_bootm_low());
        }
 
-       if (of_start == 0) {
+       if (of_start == NULL) {
                puts("device tree - allocation error\n");
                goto error;
        }
        return 0;
 
 error:
-       *of_flat_tree = 0;
+       *of_flat_tree = NULL;
        *of_size = 0;
        return 1;
 }
 
 #define HIST_MAX               20
 #define HIST_SIZE              CONFIG_SYS_CBSIZE
 
-static int hist_max = 0;
-static int hist_add_idx = 0;
+static int hist_max;
+static int hist_add_idx;
 static int hist_cur = -1;
-unsigned hist_num = 0;
+static unsigned hist_num;
 
-char* hist_list[HIST_MAX];
-char hist_lines[HIST_MAX][HIST_SIZE + 1];       /* Save room for NULL */
+static char *hist_list[HIST_MAX];
+static char hist_lines[HIST_MAX][HIST_SIZE + 1];       /* Save room for NULL */
 
 #define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
 
 
 }
 #endif
 
-void usb_show_progress(void)
+static void usb_show_progress(void)
 {
        debug(".");
 }
        result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
                                 US_BBB_RESET,
                                 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-                                0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT * 5);
+                                0, us->ifnum, NULL, 0, USB_CNTL_TIMEOUT * 5);
 
        if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
                USB_STOR_PRINTF("RESET:stall\n");
  * Set up the command for a BBB device. Note that the actual SCSI
  * command is copied into cbw.CBWCDB.
  */
-int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
+static int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
 {
        int result;
        int actlen;
 /* FIXME: we also need a CBI_command which sets up the completion
  * interrupt, and waits for it
  */
-int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
+static int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 {
        int result = 0;
        int dir_in, retry;
 }
 
 
-int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
+static int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 {
        int timeout;
 
                        (void *) &us->ip_data, us->irqmaxp, us->irqinterval);
        timeout = 1000;
        while (timeout--) {
-               if ((volatile int *) us->ip_wanted == 0)
+               if ((volatile int *) us->ip_wanted == NULL)
                        break;
                mdelay(10);
        }
 #define USB_TRANSPORT_NOT_READY_RETRY 10
 
 /* clear a stall on an endpoint - special for BBB devices */
-int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
+static int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
 {
        int result;
 
        /* ENDPOINT_HALT = 0, so set value to 0 */
        result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
                                USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
-                               0, endpt, 0, 0, USB_CNTL_TIMEOUT * 5);
+                               0, endpt, NULL, 0, USB_CNTL_TIMEOUT * 5);
        return result;
 }
 
-int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
+static int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
 {
        int result, retry;
        int dir_in;
        return result;
 }
 
-int usb_stor_CB_transport(ccb *srb, struct us_data *us)
+static int usb_stor_CB_transport(ccb *srb, struct us_data *us)
 {
        int result, status;
        ccb *psrb;
 
 
 #ifndef REDBOOT                        /*SB */
 typedef int cyg_int32;
-int
+static int
 CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
 {
 #define DELAY 20
   return 0;
 }
 
-void
+static void
 CYGACC_COMM_IF_PUTC (char x, char y)
 {
   putc (y);
 }
 
 /* Parse (scan) a number */
-bool
+static bool
 parse_num (char *s, unsigned long *val, char **es, char *delim)
 {
   bool first = true;