done a dozen of randconfig test. guess what? ALL failed...
authorDenis Vlasenko <vda.linux@googlemail.com>
Sat, 30 Dec 2006 17:57:03 +0000 (17:57 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Sat, 30 Dec 2006 17:57:03 +0000 (17:57 -0000)
these are resulting fixes

archival/gzip.c
coreutils/chgrp.c
coreutils/diff.c
miscutils/less.c
miscutils/taskset.c
modutils/insmod.c
networking/httpd.c
procps/top.c
runit/Kbuild
util-linux/fdisk.c
util-linux/mkfs_minix.c

index f4aea3f59d2c60deff85b81ef7bfe36775de9cd0..c0671c1870cd8a95f1687bdcee78770aafa30f3a 100644 (file)
@@ -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) {
index da5b1296477548e2b1162a90d91b99dbbb600786..465ea0ccf5cb61ceb27937e1104d03e7dd7ba110 100644 (file)
@@ -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)" */
index a49d5195a7fa6a7db1e6065249f933bd607fc1dd..072e4bc208e19f6e7a2839aa3f6b486e0488a0b2 100644 (file)
@@ -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;
index 60c54e61018c8c783b4af550af4f20752048c15d..807a5bf4760bb826499d050cd7232f29f0d5ad16 100644 (file)
@@ -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)
index 4496aa5b4b2497dbb6f257ad08ada6da5df67bc2..a4d41ac9c3f716d3116fe5cfec33df68c4c41bc6 100644 (file)
@@ -8,14 +8,14 @@
 
 #include "busybox.h"
 #include <sched.h>
-#include <unistd.h>
 #include <getopt.h> /* 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> <pid> */
                        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
index 3b71d1c8acb1745a1cb4f1d8bd637d437966d9fc..842ef09d0394d7513d24948944cdd03cef9b7c1a 100644 (file)
@@ -63,6 +63,7 @@
 #include <sys/utsname.h>
 
 #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
 
index 49c2c76beb432814db37ceed46511ced90e49157..e50955ddc12af992eb7a3fd4a3dcd85b0de0dbe0 100644 (file)
@@ -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
 
index 8d732d4b28dc29c42ef1eaf337bb87a95ccfb29b..d1fbfe6e139dbafa6b675f77cd85efb8abcf5366 100644 (file)
@@ -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);
index ad1706cb6c0581632cd412024054da2c54cae8fb..ab9eef6ff27099d520e0f9e4975789d942d7f9dd 100644 (file)
@@ -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
index 84538af99dc7c596ec0f56cf80a0c2b913ce2a3b..64ebb60e37d3fc22f27cbcc5550f1bbd09861b8d 100644 (file)
@@ -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) {
index 263013af9a785c3dde749f4cc9e2a4a2ed929903..89874b6b805eccec6902749eacd86638743d8bda 100644 (file)
@@ -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)