done a dozen of randconfig test. guess what? ALL failed...

these are resulting fixes
This commit is contained in:
Denis Vlasenko 2006-12-30 17:57:03 +00:00
parent b5a122b6f9
commit 3bba545a54
11 changed files with 71 additions and 43 deletions

View File

@ -1122,7 +1122,7 @@ static ulg deflate(void)
* in the compressed file. * in the compressed file.
*/ */
/* configuration */ /* configuration */
typedef struct dirent dir_type; typedef struct dirent dir_type;
@ -1156,11 +1156,13 @@ int gzip_main(int argc, char **argv)
//if (opt & 0x400) // -9 //if (opt & 0x400) // -9
//if (opt & 0x800) // -q //if (opt & 0x800) // -q
//if (opt & 0x1000) // -v //if (opt & 0x1000) // -v
if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d #if ENABLE_GUNZIP /* gunzip_main may not be visible... */
if (opt & 0x2000) { // -d
/* FIXME: getopt32 should not depend on optind */ /* FIXME: getopt32 should not depend on optind */
optind = 1; optind = 1;
return gunzip_main(argc, argv); return gunzip_main(argc, argv);
} }
#endif
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) { if (foreground) {

View File

@ -13,6 +13,9 @@
#include "busybox.h" #include "busybox.h"
/* FIXME - move to .h */
extern int chown_main(int argc, char **argv);
int chgrp_main(int argc, char **argv) int chgrp_main(int argc, char **argv)
{ {
/* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */

View File

@ -71,7 +71,7 @@ int context, status;
char *start, *label[2]; char *start, *label[2];
struct stat stb1, stb2; struct stat stb1, stb2;
char **dl; char **dl;
static int dl_count; USE_FEATURE_DIFF_DIR(static int dl_count;)
struct cand { struct cand {
int x; int x;

View File

@ -109,6 +109,8 @@ static int match_pos; /* signed! */
static unsigned num_matches; static unsigned num_matches;
static regex_t pattern; static regex_t pattern;
static unsigned pattern_valid; static unsigned pattern_valid;
#else
enum { pattern_valid = 0 };
#endif #endif
static struct termios term_orig, term_vi; static struct termios term_orig, term_vi;
@ -168,7 +170,7 @@ static void read_lines(void)
{ {
#define readbuf bb_common_bufsiz1 #define readbuf bb_common_bufsiz1
char *current_line, *p; char *current_line, *p;
unsigned old_max_fline = max_fline; USE_FEATURE_LESS_REGEXP(unsigned old_max_fline = max_fline;)
int w = width; int w = width;
char last_terminated = terminated; char last_terminated = terminated;
@ -337,6 +339,7 @@ static char ctrlconv[] =
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x40\x4b\x4c\x4d\x4e\x4f" "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x40\x4b\x4c\x4d\x4e\x4f"
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"; "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f";
#if ENABLE_FEATURE_LESS_REGEXP
static void print_found(const char *line) static void print_found(const char *line)
{ {
int match_status; int match_status;
@ -397,6 +400,9 @@ static void print_found(const char *line)
printf(CLEAR_2_EOL"%s%s\n", growline, str); printf(CLEAR_2_EOL"%s%s\n", growline, str);
free(growline); free(growline);
} }
#else
void print_found(const char *line);
#endif
static void print_ascii(const char *str) static void print_ascii(const char *str)
{ {
@ -718,6 +724,7 @@ static void colon_process(void)
} }
} }
#if ENABLE_FEATURE_LESS_REGEXP
static int normalize_match_pos(int match) static int normalize_match_pos(int match)
{ {
match_pos = match; match_pos = match;
@ -728,7 +735,6 @@ static int normalize_match_pos(int match)
return match_pos; return match_pos;
} }
#if ENABLE_FEATURE_LESS_REGEXP
static void goto_match(int match) static void goto_match(int match)
{ {
if (num_matches) if (num_matches)

View File

@ -8,14 +8,14 @@
#include "busybox.h" #include "busybox.h"
#include <sched.h> #include <sched.h>
#include <unistd.h>
#include <getopt.h> /* optind */ #include <getopt.h> /* optind */
#if ENABLE_FEATURE_TASKSET_FANCY #if ENABLE_FEATURE_TASKSET_FANCY
#define TASKSET_PRINTF_MASK "%s" #define TASKSET_PRINTF_MASK "%s"
#define from_cpuset(x) __from_cpuset(&x) #define from_cpuset(x) __from_cpuset(&x)
/* craft a string from the mask */ /* craft a string from the mask */
static char *__from_cpuset(cpu_set_t *mask) { static char *__from_cpuset(cpu_set_t *mask)
{
int i; int i;
char *ret = 0, *str = xzalloc(9); char *ret = 0, *str = xzalloc(9);
@ -34,22 +34,24 @@ static char *__from_cpuset(cpu_set_t *mask) {
} }
#else #else
#define TASKSET_PRINTF_MASK "%x" #define TASKSET_PRINTF_MASK "%x"
#define from_cpuset(mask) mask /* (void*) cast is for battling gcc: */
/* "dereferencing type-punned pointer will break strict-aliasing rules" */
#define from_cpuset(mask) (*(unsigned*)(void*)&(mask))
#endif #endif
#define TASKSET_OPT_p (1) #define OPT_p 1
int taskset_main(int argc, char** argv) int taskset_main(int argc, char** argv)
{ {
cpu_set_t mask, new_mask; cpu_set_t mask, new_mask;
pid_t pid = 0; pid_t pid = 0;
unsigned long ul; unsigned opt;
const char *state = "current\0new"; const char *state = "current\0new";
char *p_opt = NULL, *aff = NULL; char *p_opt = NULL, *aff = NULL;
ul = getopt32(argc, argv, "+p:", &p_opt); opt = getopt32(argc, argv, "+p:", &p_opt);
if (ul & TASKSET_OPT_p) { if (opt & OPT_p) {
if (argc == optind+1) { /* -p <aff> <pid> */ if (argc == optind+1) { /* -p <aff> <pid> */
aff = p_opt; aff = p_opt;
p_opt = argv[optind]; p_opt = argv[optind];
@ -70,19 +72,19 @@ int taskset_main(int argc, char** argv)
} }
} }
if (ul & TASKSET_OPT_p) { if (opt & OPT_p) {
print_aff: print_aff:
if (sched_getaffinity(pid, sizeof (mask), &mask) < 0) if (sched_getaffinity(pid, sizeof(mask), &mask) < 0)
bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 'g', pid); bb_perror_msg_and_die("failed to %cet pid %d's affinity", 'g', pid);
printf("pid %d's %s affinity mask: "TASKSET_PRINTF_MASK"\n", printf("pid %d's %s affinity mask: "TASKSET_PRINTF_MASK"\n",
pid, state, from_cpuset(mask)); pid, state, from_cpuset(mask));
if (!*argv) /* no new affinity given or we did print already, done. */ if (!*argv) /* no new affinity given or we did print already, done. */
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (sched_setaffinity(pid, sizeof (new_mask), &new_mask)) if (sched_setaffinity(pid, sizeof(new_mask), &new_mask))
bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 's', pid); bb_perror_msg_and_die("failed to %cet pid %d's affinity", 's', pid);
if (ul & TASKSET_OPT_p) { if (opt & OPT_p) {
state += 8; state += 8;
++argv; ++argv;
goto print_aff; goto print_aff;
@ -91,6 +93,6 @@ print_aff:
execvp(*argv, argv); execvp(*argv, argv);
bb_perror_msg_and_die("%s", *argv); bb_perror_msg_and_die("%s", *argv);
} }
#undef TASKSET_OPT_p #undef OPT_p
#undef TASKSET_PRINTF_MASK #undef TASKSET_PRINTF_MASK
#undef from_cpuset #undef from_cpuset

View File

@ -63,6 +63,7 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES #if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES
#undef ENABLE_FEATURE_2_4_MODULES
#define ENABLE_FEATURE_2_4_MODULES 1 #define ENABLE_FEATURE_2_4_MODULES 1
#endif #endif

View File

@ -338,7 +338,9 @@ static int scan_ip_mask(const char *ipm, unsigned int *ip, unsigned int *mask)
return 0; return 0;
} }
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
static void free_config_lines(Htaccess **pprev) static void free_config_lines(Htaccess **pprev)
{ {
Htaccess *prev = *pprev; Htaccess *prev = *pprev;
@ -387,8 +389,11 @@ static void parse_conf(const char *path, int flag)
{ {
FILE *f; FILE *f;
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH #if ENABLE_FEATURE_HTTPD_BASIC_AUTH
Htaccess *prev, *cur; Htaccess *prev;
#elif ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES #endif
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
Htaccess *cur; Htaccess *cur;
#endif #endif
@ -410,7 +415,9 @@ static void parse_conf(const char *path, int flag)
config->flg_deny_all = 0; config->flg_deny_all = 0;
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
/* retain previous auth and mime config only for subdir parse */ /* retain previous auth and mime config only for subdir parse */
if (flag != SUBDIR_PARSE) { if (flag != SUBDIR_PARSE) {
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH #if ENABLE_FEATURE_HTTPD_BASIC_AUTH
@ -559,7 +566,9 @@ static void parse_conf(const char *path, int flag)
} }
#endif #endif
#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR #if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
|| ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
/* storing current config line */ /* storing current config line */
cur = calloc(1, sizeof(Htaccess) + strlen(p0)); cur = calloc(1, sizeof(Htaccess) + strlen(p0));
if (cur) { if (cur) {
@ -1305,8 +1314,9 @@ static int checkPermIP(void)
/* This could stand some work */ /* This could stand some work */
for (cur = config->ip_a_d; cur; cur = cur->next) { for (cur = config->ip_a_d; cur; cur = cur->next) {
if (DEBUG) #if DEBUG
fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str); fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str);
#endif
if (DEBUG) if (DEBUG)
fprintf(stderr, "'%u.%u.%u.%u/%u.%u.%u.%u'\n", fprintf(stderr, "'%u.%u.%u.%u/%u.%u.%u.%u'\n",
(unsigned char)(cur->ip >> 24), (unsigned char)(cur->ip >> 24),
@ -1589,7 +1599,8 @@ static void handleIncoming(void)
/* extra read only for POST */ /* extra read only for POST */
if (prequest != request_GET) { if (prequest != request_GET) {
test = buf + sizeof("Content-length:")-1; test = buf + sizeof("Content-length:")-1;
if (!test[0]) goto bail_out; if (!test[0])
goto bail_out;
errno = 0; errno = 0;
/* not using strtoul: it ignores leading munis! */ /* not using strtoul: it ignores leading munis! */
length = strtol(test, &test, 10); length = strtol(test, &test, 10);
@ -1690,7 +1701,9 @@ static void handleIncoming(void)
config->ContentLength = -1; config->ContentLength = -1;
} while (0); } while (0);
#if ENABLE_FEATURE_HTTPD_CGI
bail_out: bail_out:
#endif
if (DEBUG) if (DEBUG)
fprintf(stderr, "closing socket\n\n"); fprintf(stderr, "closing socket\n\n");
@ -1910,20 +1923,9 @@ int httpd_main(int argc, char *argv[])
#if ENABLE_FEATURE_HTTPD_SETUID #if ENABLE_FEATURE_HTTPD_SETUID
if (opt & OPT_SETUID) { if (opt & OPT_SETUID) {
char *e; if (!get_uidgid(&ugid, s_ugid, 1))
// FIXME: what the default group should be? bb_error_msg_and_die("unrecognized user[:group] "
ugid.gid = -1;
ugid.uid = bb_strtoul(s_ugid, &e, 0);
if (*e == ':') {
e++;
ugid.gid = bb_strtoul(e, NULL, 0);
}
if (errno) {
/* not integer */
if (!uidgid_get(&ugid, s_ugid))
bb_error_msg_and_die("unrecognized user[:group] "
"name '%s'", s_ugid); "name '%s'", s_ugid);
}
} }
#endif #endif

View File

@ -50,12 +50,13 @@ struct save_hist {
unsigned long ticks; unsigned long ticks;
unsigned pid; unsigned pid;
}; };
#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
static struct save_hist *prev_hist; static struct save_hist *prev_hist;
static int prev_hist_count; static int prev_hist_count;
/* static int hist_iterations; */ /* static int hist_iterations; */
static unsigned total_pcpu; static unsigned total_pcpu;
/* static unsigned long total_rss; */ /* static unsigned long total_rss; */
#endif
#define OPT_BATCH_MODE (option_mask32 & 0x4) #define OPT_BATCH_MODE (option_mask32 & 0x4)
@ -485,7 +486,9 @@ int top_main(int argc, char **argv)
top[n].pid = p->pid; top[n].pid = p->pid;
top[n].ppid = p->ppid; top[n].ppid = p->ppid;
top[n].rss = p->rss; top[n].rss = p->rss;
#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
top[n].ticks = p->stime + p->utime; top[n].ticks = p->stime + p->utime;
#endif
top[n].uid = p->uid; top[n].uid = p->uid;
strcpy(top[n].state, p->state); strcpy(top[n].state, p->state);
strcpy(top[n].comm, p->comm); strcpy(top[n].comm, p->comm);

View File

@ -10,3 +10,8 @@ lib-$(CONFIG_RUNSVDIR) += runsvdir.o runit_lib.o
lib-$(CONFIG_SV) += sv.o runit_lib.o lib-$(CONFIG_SV) += sv.o runit_lib.o
lib-$(CONFIG_SVLOGD) += svlogd.o runit_lib.o lib-$(CONFIG_SVLOGD) += svlogd.o runit_lib.o
lib-$(CONFIG_CHPST) += chpst.o lib-$(CONFIG_CHPST) += chpst.o
lib-$(CONFIG_ENVDIR) += chpst.o
lib-$(CONFIG_ENVUIDGID) += chpst.o
lib-$(CONFIG_SETUIDGID) += chpst.o
lib-$(CONFIG_SOFTLIMIT) += chpst.o

View File

@ -2797,7 +2797,6 @@ int fdisk_main(int argc, char **argv)
{ {
char *str_b, *str_C, *str_H, *str_S; char *str_b, *str_C, *str_H, *str_S;
unsigned opt; unsigned opt;
int c;
/* /*
* fdisk -v * fdisk -v
* fdisk -l [-b sectorsize] [-u] device ... * fdisk -l [-b sectorsize] [-u] device ...
@ -2921,6 +2920,7 @@ int fdisk_main(int argc, char **argv)
} }
while (1) { while (1) {
int c;
putchar('\n'); putchar('\n');
c = tolower(read_nonempty(_("Command (m for help): "))); c = tolower(read_nonempty(_("Command (m for help): ")));
switch (c) { switch (c) {

View File

@ -453,6 +453,8 @@ static void make_bad_inode2(void)
if (dind) if (dind)
write_block(dind, (char *) dind_block); write_block(dind, (char *) dind_block);
} }
#else
void make_bad_inode2(void);
#endif #endif
static void make_root_inode(void) static void make_root_inode(void)
@ -499,6 +501,8 @@ static void make_root_inode2(void)
inode->i_gid = GETGID; inode->i_gid = GETGID;
write_block(inode->i_zone[0], root_block); write_block(inode->i_zone[0], root_block);
} }
#else
void make_root_inode2(void);
#endif #endif
static void setup_tables(void) static void setup_tables(void)