add some missed statics on constant objects.

fix few #ifndef ENABLE_xxx

# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 677152    2920   18208  698280   aa7a8 busybox_old
 676420    2920   18208  697548   aa4cc busybox_unstripped
This commit is contained in:
Denis Vlasenko 2007-04-08 16:07:02 +00:00
parent 5694d5f8d2
commit 240a1cfbbe
10 changed files with 40 additions and 35 deletions

View File

@ -69,15 +69,15 @@ int date_main(int argc, char **argv)
if (!isofmt_arg) { if (!isofmt_arg) {
ifmt = 0; /* default is date */ ifmt = 0; /* default is date */
} else { } else {
const char * const isoformats[] = static const char * const isoformats[] =
{"date", "hours", "minutes", "seconds"}; { "date", "hours", "minutes", "seconds" };
for (ifmt = 0; ifmt < 4; ifmt++) for (ifmt = 0; ifmt < 4; ifmt++)
if (!strcmp(isofmt_arg, isoformats[ifmt])) { if (!strcmp(isofmt_arg, isoformats[ifmt]))
break; goto found;
} /* parse error */
if (ifmt == 4) /* parse error */ bb_show_usage();
bb_show_usage(); found: ;
} }
} }
@ -207,7 +207,7 @@ int date_main(int argc, char **argv)
date_fmt[i++] = '%'; date_fmt[i++] = '%';
date_fmt[i++] = 'S'; date_fmt[i++] = 'S';
} }
format_utc: format_utc:
date_fmt[i++] = '%'; date_fmt[i++] = '%';
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z'; date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
} }

View File

@ -75,7 +75,7 @@ int dd_main(int argc, char **argv)
trunc_flag = 1 << 2, trunc_flag = 1 << 2,
twobufs_flag = 1 << 3, twobufs_flag = 1 << 3,
}; };
const char * const keywords[] = { static const char * const keywords[] = {
"bs=", "count=", "seek=", "skip=", "if=", "of=", "bs=", "count=", "seek=", "skip=", "if=", "of=",
#if ENABLE_FEATURE_DD_IBS_OBS #if ENABLE_FEATURE_DD_IBS_OBS
"ibs=", "obs=", "conv=", "notrunc", "sync", "noerror", "ibs=", "obs=", "conv=", "notrunc", "sync", "noerror",

View File

@ -278,7 +278,7 @@ static VALUE *eval7(void)
static VALUE *eval6(void) static VALUE *eval6(void)
{ {
VALUE *l, *r, *v = NULL /* silence gcc */, *i1, *i2; VALUE *l, *r, *v = NULL /* silence gcc */, *i1, *i2;
const char * const keywords[] = { static const char * const keywords[] = {
"quote", "length", "match", "index", "substr", NULL "quote", "length", "match", "index", "substr", NULL
}; };

View File

@ -68,7 +68,7 @@ static char const *human_time(time_t t)
static char const *human_fstype(long f_type) static char const *human_fstype(long f_type)
{ {
int i; int i;
const struct types { static const struct types {
long type; long type;
const char * const fs; const char * const fs;
} humantypes[] = { } humantypes[] = {
@ -109,13 +109,13 @@ static char const *human_fstype(long f_type)
{ 0x62656572, "sysfs" }, { 0x62656572, "sysfs" },
{ 0, "UNKNOWN" } { 0, "UNKNOWN" }
}; };
for (i=0; humantypes[i].type; ++i) for (i = 0; humantypes[i].type; ++i)
if (humantypes[i].type == f_type) if (humantypes[i].type == f_type)
break; break;
return humantypes[i].fs; return humantypes[i].fs;
} }
#ifdef CONFIG_FEATURE_STAT_FORMAT #if ENABLE_FEATURE_STAT_FORMAT
/* print statfs info */ /* print statfs info */
static void print_statfs(char *pformat, const size_t buf_len, const char m, static void print_statfs(char *pformat, const size_t buf_len, const char m,
const char * const filename, void const *data const char * const filename, void const *data
@ -354,9 +354,9 @@ static bool do_statfs(char const *filename, char const *format)
return 0; return 0;
} }
#ifdef CONFIG_FEATURE_STAT_FORMAT #if ENABLE_FEATURE_STAT_FORMAT
if (format == NULL) if (format == NULL)
#ifndef ENABLE_SELINUX #if !ENABLE_SELINUX
format = (option_mask32 & OPT_TERSE format = (option_mask32 & OPT_TERSE
? "%n %i %l %t %s %b %f %a %c %d\n" ? "%n %i %l %t %s %b %f %a %c %d\n"
: " File: \"%n\"\n" : " File: \"%n\"\n"
@ -460,9 +460,9 @@ static bool do_stat(char const *filename, char const *format)
return 0; return 0;
} }
#ifdef CONFIG_FEATURE_STAT_FORMAT #if ENABLE_FEATURE_STAT_FORMAT
if (format == NULL) { if (format == NULL) {
#ifndef ENABLE_SELINUX #if !ENABLE_SELINUX
if (option_mask32 & OPT_TERSE) { if (option_mask32 & OPT_TERSE) {
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o"; format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o";
} else { } else {

View File

@ -388,7 +388,7 @@ static const char *device_name = bb_msg_standard_input;
/* Return a string that is the printable representation of character CH */ /* Return a string that is the printable representation of character CH */
/* Adapted from 'cat' by Torbjorn Granlund */ /* Adapted from 'cat' by Torbjorn Granlund */
static const char *visible(unsigned int ch) static const char *visible(unsigned ch)
{ {
char *bpout = G.buf; char *bpout = G.buf;
@ -561,18 +561,18 @@ enum {
static int find_param(const char * const name) static int find_param(const char * const name)
{ {
const char * const params[] = { static const char * const params[] = {
"line", "line",
"rows", "rows",
"cols", "cols",
"columns", "columns",
"size", "size", /* 4 */
"speed", "speed", /* 5 */
"ispeed", "ispeed",
"ospeed", "ospeed",
NULL NULL
}; };
smalluint i = index_in_str_array(params, name) + 1; int i = index_in_str_array(params, name) + 1;
if (i == 0) if (i == 0)
return 0; return 0;
if (!(i == 4 || i == 5)) if (!(i == 4 || i == 5))
@ -584,7 +584,7 @@ static int find_param(const char * const name)
static int recover_mode(const char *arg, struct termios *mode) static int recover_mode(const char *arg, struct termios *mode)
{ {
int i, n; int i, n;
unsigned int chr; unsigned chr;
unsigned long iflag, oflag, cflag, lflag; unsigned long iflag, oflag, cflag, lflag;
/* Scan into temporaries since it is too much trouble to figure out /* Scan into temporaries since it is too much trouble to figure out
@ -612,7 +612,7 @@ static int recover_mode(const char *arg, struct termios *mode)
} }
static void display_recoverable(const struct termios *mode, static void display_recoverable(const struct termios *mode,
const int ATTRIBUTE_UNUSED dummy) int ATTRIBUTE_UNUSED dummy)
{ {
int i; int i;
printf("%lx:%lx:%lx:%lx", printf("%lx:%lx:%lx:%lx",
@ -975,7 +975,7 @@ int stty_main(int argc, char **argv)
goto invalid_argument; goto invalid_argument;
} }
} }
end_option: end_option:
continue; continue;
} }
@ -1031,7 +1031,7 @@ end_option:
default: default:
if (recover_mode(arg, &mode) == 1) break; if (recover_mode(arg, &mode) == 1) break;
if (tty_value_to_baud(xatou(arg)) != (speed_t) -1) break; if (tty_value_to_baud(xatou(arg)) != (speed_t) -1) break;
invalid_argument: invalid_argument:
bb_error_msg_and_die("invalid argument '%s'", arg); bb_error_msg_and_die("invalid argument '%s'", arg);
} }
stty_state &= ~STTY_noargs; stty_state &= ~STTY_noargs;

View File

@ -84,7 +84,7 @@ static unsigned int expand(const char *arg, char *buffer)
unsigned i; /* XXX: FIXME: use unsigned char? */ unsigned i; /* XXX: FIXME: use unsigned char? */
unsigned char ac; unsigned char ac;
#define CLO ":]" #define CLO ":]"
const char * const classes[] = { static const char * const classes[] = {
"alpha"CLO, "alnum"CLO, "digit"CLO, "lower"CLO, "upper"CLO, "space"CLO, "alpha"CLO, "alnum"CLO, "digit"CLO, "lower"CLO, "upper"CLO, "space"CLO,
"blank"CLO, "punct"CLO, "cntrl"CLO, NULL "blank"CLO, "punct"CLO, "cntrl"CLO, NULL
}; };

View File

@ -6967,6 +6967,11 @@ tokname(int tok)
{ {
static char buf[16]; static char buf[16];
//try this:
//if (tok < TSEMI) return tokname_array[tok] + 1;
//sprintf(buf, "\"%s\"", tokname_array[tok] + 1);
//return buf;
if (tok >= TSEMI) if (tok >= TSEMI)
buf[0] = '"'; buf[0] = '"';
sprintf(buf + (tok >= TSEMI), "%s%c", sprintf(buf + (tok >= TSEMI), "%s%c",
@ -6978,15 +6983,15 @@ tokname(int tok)
static int static int
pstrcmp(const void *a, const void *b) pstrcmp(const void *a, const void *b)
{ {
return strcmp((const char *) a, (*(const char *const *) b) + 1); return strcmp((char*) a, (*(char**) b) + 1);
} }
static const char *const * static const char *const *
findkwd(const char *s) findkwd(const char *s)
{ {
return bsearch(s, tokname_array + KWDOFFSET, return bsearch(s, tokname_array + KWDOFFSET,
(sizeof(tokname_array) / sizeof(const char *)) - KWDOFFSET, (sizeof(tokname_array) / sizeof(char *)) - KWDOFFSET,
sizeof(const char *), pstrcmp); sizeof(char *), pstrcmp);
} }
/* /*

View File

@ -716,11 +716,12 @@ static char * strsep_space(char *string, int * ix)
static int expand_arguments(char *command) static int expand_arguments(char *command)
{ {
static const char out_of_space[] = "out of space during expansion";
int total_length = 0, length, i, retval, ix = 0; int total_length = 0, length, i, retval, ix = 0;
expand_t expand_result; expand_t expand_result;
char *tmpcmd, *cmd, *cmd_copy; char *tmpcmd, *cmd, *cmd_copy;
char *src, *dst, *var; char *src, *dst, *var;
const char * const out_of_space = "out of space during expansion";
int flags = GLOB_NOCHECK int flags = GLOB_NOCHECK
#ifdef GLOB_BRACE #ifdef GLOB_BRACE
| GLOB_BRACE | GLOB_BRACE

View File

@ -154,7 +154,6 @@ int ipcrm_main(int argc, char **argv)
if (id < 0) { if (id < 0) {
const char *errmsg; const char *errmsg;
const char *const what = "key";
error++; error++;
switch (errno) { switch (errno) {
@ -171,7 +170,7 @@ int ipcrm_main(int argc, char **argv)
errmsg = "unknown error in"; errmsg = "unknown error in";
break; break;
} }
bb_error_msg("%s %s (%s)", errmsg, what, optarg); bb_error_msg("%s %s (%s)", errmsg, "key", optarg);
continue; continue;
} }
} else { } else {

View File

@ -891,7 +891,7 @@ static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts)
for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) { for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) {
char *opteq = strchr(opt, '='); char *opteq = strchr(opt, '=');
if (opteq) { if (opteq) {
const char *const options[] = { static const char *const options[] = {
/* 0 */ "rsize", /* 0 */ "rsize",
/* 1 */ "wsize", /* 1 */ "wsize",
/* 2 */ "timeo", /* 2 */ "timeo",
@ -996,7 +996,7 @@ static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts)
} }
} }
else { else {
const char *const options[] = { static const char *const options[] = {
"bg", "bg",
"fg", "fg",
"soft", "soft",