summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/command.c9
-rw-r--r--common/dlmalloc.c36
-rw-r--r--common/hush.c31
-rw-r--r--common/image.c8
-rw-r--r--common/main.c10
-rw-r--r--common/usb_storage.c20
-rw-r--r--common/xyzModem.c6
7 files changed, 64 insertions, 56 deletions
diff --git a/common/command.c b/common/command.c
index 50c84292c1..f51df26bf9 100644
--- a/common/command.c
+++ b/common/command.c
@@ -40,8 +40,15 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
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 */
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 1d7e527b9d..b2f0a1ad52 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1465,7 +1465,7 @@ typedef struct malloc_chunk* mbinptr;
#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),
@@ -2173,10 +2173,10 @@ Void_t* mALLOc(bytes) size_t bytes;
/* 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; */
@@ -2379,7 +2379,7 @@ Void_t* mALLOc(bytes) size_t bytes;
/* 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;
@@ -2433,7 +2433,7 @@ void fREe(mem) Void_t* mem;
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);
@@ -2579,10 +2579,10 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
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);
@@ -2643,7 +2643,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
}
else
{
- next = 0;
+ next = NULL;
nextsize = 0;
}
@@ -2656,7 +2656,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
/* try forward + backward first to save a later consolidation */
- if (next != 0)
+ if (next != NULL)
{
/* into top */
if (next == top)
@@ -2689,7 +2689,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
}
/* backward only */
- if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
+ if (prev != NULL && (long)(prevsize + newsize) >= (long)nb)
{
unlink(prev, bck, fwd);
newp = prev;
@@ -2704,8 +2704,8 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
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.) */
@@ -2783,7 +2783,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
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 */
@@ -2798,7 +2798,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
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);
@@ -2923,10 +2923,10 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
#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);
@@ -3072,7 +3072,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
#endif
{
mchunkptr p;
- if (mem == 0)
+ if (mem == NULL)
return 0;
else
{
diff --git a/common/hush.c b/common/hush.c
index 4c84c2f501..eb6c879c53 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -289,8 +289,7 @@ struct variables {
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
@@ -2172,7 +2171,7 @@ int set_local_var(const char *s, int flg_export)
* 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;
}
@@ -2207,13 +2206,13 @@ int set_local_var(const char *s, int flg_export)
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;
@@ -2246,7 +2245,7 @@ void unset_local_var(const char *name)
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);
@@ -2329,7 +2328,8 @@ static int setup_redirect(struct p_context *ctx, int fd, redir_type style,
}
#endif
-struct pipe *new_pipe(void) {
+static struct pipe *new_pipe(void)
+{
struct pipe *pi;
pi = xmalloc(sizeof(struct pipe));
pi->num_progs = 0;
@@ -2387,7 +2387,7 @@ static struct reserved_combo reserved_list[] = {
};
#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;
@@ -2924,8 +2924,8 @@ int parse_string(o_string *dest, struct p_context *ctx, const char *src)
#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__
@@ -3124,13 +3124,13 @@ int parse_stream(o_string *dest, struct p_context *ctx,
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");
@@ -3158,7 +3158,7 @@ void update_ifs_map(void)
/* 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;
@@ -3292,7 +3292,7 @@ int u_boot_hush_start(void)
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
@@ -3628,7 +3628,8 @@ static char * make_string(char ** inp)
}
#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;
diff --git a/common/image.c b/common/image.c
index 750a98b6ba..df642e656c 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1279,7 +1279,7 @@ void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob)
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;
@@ -1312,7 +1312,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
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;
}
@@ -1327,7 +1327,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
+ getenv_bootm_low());
}
- if (of_start == 0) {
+ if (of_start == NULL) {
puts("device tree - allocation error\n");
goto error;
}
@@ -1703,7 +1703,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[],
return 0;
error:
- *of_flat_tree = 0;
+ *of_flat_tree = NULL;
*of_size = 0;
return 1;
}
diff --git a/common/main.c b/common/main.c
index 9507cec88b..592ce077d2 100644
--- a/common/main.c
+++ b/common/main.c
@@ -505,13 +505,13 @@ void reset_cmd_timeout(void)
#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)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 0c2a4c718f..2d92ee1bb3 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -192,7 +192,7 @@ block_dev_desc_t *usb_stor_get_dev(int index)
}
#endif
-void usb_show_progress(void)
+static void usb_show_progress(void)
{
debug(".");
}
@@ -437,7 +437,7 @@ static int usb_stor_BBB_reset(struct us_data *us)
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");
@@ -500,7 +500,7 @@ static int usb_stor_CB_reset(struct us_data *us)
* 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;
@@ -548,7 +548,7 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
/* 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;
@@ -617,7 +617,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
}
-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;
@@ -626,7 +626,7 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
(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);
}
@@ -665,18 +665,18 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
#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;
@@ -798,7 +798,7 @@ again:
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;
diff --git a/common/xyzModem.c b/common/xyzModem.c
index a1f955b9d7..f30b0020a3 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -100,7 +100,7 @@ static struct
#ifndef REDBOOT /*SB */
typedef int cyg_int32;
-int
+static int
CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
{
#define DELAY 20
@@ -118,7 +118,7 @@ CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
return 0;
}
-void
+static void
CYGACC_COMM_IF_PUTC (char x, char y)
{
putc (y);
@@ -165,7 +165,7 @@ _tolower (char c)
}
/* Parse (scan) a number */
-bool
+static bool
parse_num (char *s, unsigned long *val, char **es, char *delim)
{
bool first = true;