From 3bba545a54addf59b63a003e7ada03fd8b29b5ba Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 30 Dec 2006 17:57:03 +0000 Subject: done a dozen of randconfig test. guess what? ALL failed... these are resulting fixes --- archival/gzip.c | 6 ++++-- coreutils/chgrp.c | 3 +++ coreutils/diff.c | 2 +- miscutils/less.c | 10 ++++++++-- miscutils/taskset.c | 32 +++++++++++++++++--------------- modutils/insmod.c | 1 + networking/httpd.c | 44 +++++++++++++++++++++++--------------------- procps/top.c | 5 ++++- runit/Kbuild | 5 +++++ util-linux/fdisk.c | 2 +- util-linux/mkfs_minix.c | 4 ++++ 11 files changed, 71 insertions(+), 43 deletions(-) diff --git a/archival/gzip.c b/archival/gzip.c index f4aea3f59..c0671c187 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -1122,7 +1122,7 @@ static ulg deflate(void) * in the compressed file. */ - /* configuration */ +/* configuration */ typedef struct dirent dir_type; @@ -1156,11 +1156,13 @@ int gzip_main(int argc, char **argv) //if (opt & 0x400) // -9 //if (opt & 0x800) // -q //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 */ optind = 1; return gunzip_main(argc, argv); } +#endif foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; if (foreground) { diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c index da5b12964..465ea0ccf 100644 --- a/coreutils/chgrp.c +++ b/coreutils/chgrp.c @@ -13,6 +13,9 @@ #include "busybox.h" +/* FIXME - move to .h */ +extern int chown_main(int argc, char **argv); + int chgrp_main(int argc, char **argv) { /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ diff --git a/coreutils/diff.c b/coreutils/diff.c index a49d5195a..072e4bc20 100644 --- a/coreutils/diff.c +++ b/coreutils/diff.c @@ -71,7 +71,7 @@ int context, status; char *start, *label[2]; struct stat stb1, stb2; char **dl; -static int dl_count; +USE_FEATURE_DIFF_DIR(static int dl_count;) struct cand { int x; diff --git a/miscutils/less.c b/miscutils/less.c index 60c54e610..807a5bf47 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -109,6 +109,8 @@ static int match_pos; /* signed! */ static unsigned num_matches; static regex_t pattern; static unsigned pattern_valid; +#else +enum { pattern_valid = 0 }; #endif static struct termios term_orig, term_vi; @@ -168,7 +170,7 @@ static void read_lines(void) { #define readbuf bb_common_bufsiz1 char *current_line, *p; - unsigned old_max_fline = max_fline; + USE_FEATURE_LESS_REGEXP(unsigned old_max_fline = max_fline;) int w = width; 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" "\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) { int match_status; @@ -397,6 +400,9 @@ static void print_found(const char *line) printf(CLEAR_2_EOL"%s%s\n", growline, str); free(growline); } +#else +void print_found(const char *line); +#endif 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) { match_pos = match; @@ -728,7 +735,6 @@ static int normalize_match_pos(int match) return match_pos; } -#if ENABLE_FEATURE_LESS_REGEXP static void goto_match(int match) { if (num_matches) diff --git a/miscutils/taskset.c b/miscutils/taskset.c index 4496aa5b4..a4d41ac9c 100644 --- a/miscutils/taskset.c +++ b/miscutils/taskset.c @@ -8,14 +8,14 @@ #include "busybox.h" #include -#include #include /* optind */ #if ENABLE_FEATURE_TASKSET_FANCY #define TASKSET_PRINTF_MASK "%s" #define from_cpuset(x) __from_cpuset(&x) /* craft a string from the mask */ -static char *__from_cpuset(cpu_set_t *mask) { +static char *__from_cpuset(cpu_set_t *mask) +{ int i; char *ret = 0, *str = xzalloc(9); @@ -34,22 +34,24 @@ static char *__from_cpuset(cpu_set_t *mask) { } #else #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 -#define TASKSET_OPT_p (1) +#define OPT_p 1 int taskset_main(int argc, char** argv) { cpu_set_t mask, new_mask; pid_t pid = 0; - unsigned long ul; + unsigned opt; const char *state = "current\0new"; 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 = p_opt; p_opt = argv[optind]; @@ -70,19 +72,19 @@ int taskset_main(int argc, char** argv) } } - if (ul & TASKSET_OPT_p) { -print_aff: - if (sched_getaffinity(pid, sizeof (mask), &mask) < 0) - bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 'g', pid); + if (opt & OPT_p) { + print_aff: + if (sched_getaffinity(pid, sizeof(mask), &mask) < 0) + 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", pid, state, from_cpuset(mask)); if (!*argv) /* no new affinity given or we did print already, done. */ return EXIT_SUCCESS; } - if (sched_setaffinity(pid, sizeof (new_mask), &new_mask)) - bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 's', pid); - if (ul & TASKSET_OPT_p) { + if (sched_setaffinity(pid, sizeof(new_mask), &new_mask)) + bb_perror_msg_and_die("failed to %cet pid %d's affinity", 's', pid); + if (opt & OPT_p) { state += 8; ++argv; goto print_aff; @@ -91,6 +93,6 @@ print_aff: execvp(*argv, argv); bb_perror_msg_and_die("%s", *argv); } -#undef TASKSET_OPT_p +#undef OPT_p #undef TASKSET_PRINTF_MASK #undef from_cpuset diff --git a/modutils/insmod.c b/modutils/insmod.c index 3b71d1c8a..842ef09d0 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -63,6 +63,7 @@ #include #if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES +#undef ENABLE_FEATURE_2_4_MODULES #define ENABLE_FEATURE_2_4_MODULES 1 #endif diff --git a/networking/httpd.c b/networking/httpd.c index 49c2c76be..e50955ddc 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -338,7 +338,9 @@ static int scan_ip_mask(const char *ipm, unsigned int *ip, unsigned int *mask) 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) { Htaccess *prev = *pprev; @@ -387,8 +389,11 @@ static void parse_conf(const char *path, int flag) { FILE *f; #if ENABLE_FEATURE_HTTPD_BASIC_AUTH - Htaccess *prev, *cur; -#elif ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES + Htaccess *prev; +#endif +#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \ + || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ + || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR Htaccess *cur; #endif @@ -410,7 +415,9 @@ static void parse_conf(const char *path, int flag) 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 */ if (flag != SUBDIR_PARSE) { #if ENABLE_FEATURE_HTTPD_BASIC_AUTH @@ -559,7 +566,9 @@ static void parse_conf(const char *path, int flag) } #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 */ cur = calloc(1, sizeof(Htaccess) + strlen(p0)); if (cur) { @@ -1305,8 +1314,9 @@ static int checkPermIP(void) /* This could stand some work */ for (cur = config->ip_a_d; cur; cur = cur->next) { - if (DEBUG) - fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str); +#if DEBUG + fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str); +#endif if (DEBUG) fprintf(stderr, "'%u.%u.%u.%u/%u.%u.%u.%u'\n", (unsigned char)(cur->ip >> 24), @@ -1589,7 +1599,8 @@ static void handleIncoming(void) /* extra read only for POST */ if (prequest != request_GET) { test = buf + sizeof("Content-length:")-1; - if (!test[0]) goto bail_out; + if (!test[0]) + goto bail_out; errno = 0; /* not using strtoul: it ignores leading munis! */ length = strtol(test, &test, 10); @@ -1690,7 +1701,9 @@ static void handleIncoming(void) config->ContentLength = -1; } while (0); +#if ENABLE_FEATURE_HTTPD_CGI bail_out: +#endif if (DEBUG) fprintf(stderr, "closing socket\n\n"); @@ -1910,20 +1923,9 @@ int httpd_main(int argc, char *argv[]) #if ENABLE_FEATURE_HTTPD_SETUID if (opt & OPT_SETUID) { - char *e; - // FIXME: what the default group should be? - 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] " + if (!get_uidgid(&ugid, s_ugid, 1)) + bb_error_msg_and_die("unrecognized user[:group] " "name '%s'", s_ugid); - } } #endif diff --git a/procps/top.c b/procps/top.c index 8d732d4b2..d1fbfe6e1 100644 --- a/procps/top.c +++ b/procps/top.c @@ -50,12 +50,13 @@ struct save_hist { unsigned long ticks; unsigned pid; }; +#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE static struct save_hist *prev_hist; static int prev_hist_count; /* static int hist_iterations; */ static unsigned total_pcpu; /* static unsigned long total_rss; */ - +#endif #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].ppid = p->ppid; top[n].rss = p->rss; +#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE top[n].ticks = p->stime + p->utime; +#endif top[n].uid = p->uid; strcpy(top[n].state, p->state); strcpy(top[n].comm, p->comm); diff --git a/runit/Kbuild b/runit/Kbuild index ad1706cb6..ab9eef6ff 100644 --- a/runit/Kbuild +++ b/runit/Kbuild @@ -10,3 +10,8 @@ lib-$(CONFIG_RUNSVDIR) += runsvdir.o runit_lib.o lib-$(CONFIG_SV) += sv.o runit_lib.o lib-$(CONFIG_SVLOGD) += svlogd.o runit_lib.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 diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 84538af99..64ebb60e3 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -2797,7 +2797,6 @@ int fdisk_main(int argc, char **argv) { char *str_b, *str_C, *str_H, *str_S; unsigned opt; - int c; /* * fdisk -v * fdisk -l [-b sectorsize] [-u] device ... @@ -2921,6 +2920,7 @@ int fdisk_main(int argc, char **argv) } while (1) { + int c; putchar('\n'); c = tolower(read_nonempty(_("Command (m for help): "))); switch (c) { diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 263013af9..89874b6b8 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -453,6 +453,8 @@ static void make_bad_inode2(void) if (dind) write_block(dind, (char *) dind_block); } +#else +void make_bad_inode2(void); #endif static void make_root_inode(void) @@ -499,6 +501,8 @@ static void make_root_inode2(void) inode->i_gid = GETGID; write_block(inode->i_zone[0], root_block); } +#else +void make_root_inode2(void); #endif static void setup_tables(void) -- cgit v1.2.3