summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-30 17:57:03 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-30 17:57:03 +0000
commit3bba545a54addf59b63a003e7ada03fd8b29b5ba (patch)
tree948ce196f871abcf9410ca1521a3d2a5af6a3082
parentb5a122b6f9643fb052d31390e435397960289154 (diff)
downloadbusybox-w32-3bba545a54addf59b63a003e7ada03fd8b29b5ba.tar.gz
busybox-w32-3bba545a54addf59b63a003e7ada03fd8b29b5ba.tar.bz2
busybox-w32-3bba545a54addf59b63a003e7ada03fd8b29b5ba.zip
done a dozen of randconfig test. guess what? ALL failed...
these are resulting fixes
-rw-r--r--archival/gzip.c6
-rw-r--r--coreutils/chgrp.c3
-rw-r--r--coreutils/diff.c2
-rw-r--r--miscutils/less.c10
-rw-r--r--miscutils/taskset.c32
-rw-r--r--modutils/insmod.c1
-rw-r--r--networking/httpd.c44
-rw-r--r--procps/top.c5
-rw-r--r--runit/Kbuild5
-rw-r--r--util-linux/fdisk.c2
-rw-r--r--util-linux/mkfs_minix.c4
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)
1122 * in the compressed file. 1122 * in the compressed file.
1123 */ 1123 */
1124 1124
1125 /* configuration */ 1125/* configuration */
1126 1126
1127typedef struct dirent dir_type; 1127typedef struct dirent dir_type;
1128 1128
@@ -1156,11 +1156,13 @@ int gzip_main(int argc, char **argv)
1156 //if (opt & 0x400) // -9 1156 //if (opt & 0x400) // -9
1157 //if (opt & 0x800) // -q 1157 //if (opt & 0x800) // -q
1158 //if (opt & 0x1000) // -v 1158 //if (opt & 0x1000) // -v
1159 if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d 1159#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
1160 if (opt & 0x2000) { // -d
1160 /* FIXME: getopt32 should not depend on optind */ 1161 /* FIXME: getopt32 should not depend on optind */
1161 optind = 1; 1162 optind = 1;
1162 return gunzip_main(argc, argv); 1163 return gunzip_main(argc, argv);
1163 } 1164 }
1165#endif
1164 1166
1165 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; 1167 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
1166 if (foreground) { 1168 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 @@
13 13
14#include "busybox.h" 14#include "busybox.h"
15 15
16/* FIXME - move to .h */
17extern int chown_main(int argc, char **argv);
18
16int chgrp_main(int argc, char **argv) 19int chgrp_main(int argc, char **argv)
17{ 20{
18 /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */ 21 /* "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;
71char *start, *label[2]; 71char *start, *label[2];
72struct stat stb1, stb2; 72struct stat stb1, stb2;
73char **dl; 73char **dl;
74static int dl_count; 74USE_FEATURE_DIFF_DIR(static int dl_count;)
75 75
76struct cand { 76struct cand {
77 int x; 77 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! */
109static unsigned num_matches; 109static unsigned num_matches;
110static regex_t pattern; 110static regex_t pattern;
111static unsigned pattern_valid; 111static unsigned pattern_valid;
112#else
113enum { pattern_valid = 0 };
112#endif 114#endif
113 115
114static struct termios term_orig, term_vi; 116static struct termios term_orig, term_vi;
@@ -168,7 +170,7 @@ static void read_lines(void)
168{ 170{
169#define readbuf bb_common_bufsiz1 171#define readbuf bb_common_bufsiz1
170 char *current_line, *p; 172 char *current_line, *p;
171 unsigned old_max_fline = max_fline; 173 USE_FEATURE_LESS_REGEXP(unsigned old_max_fline = max_fline;)
172 int w = width; 174 int w = width;
173 char last_terminated = terminated; 175 char last_terminated = terminated;
174 176
@@ -337,6 +339,7 @@ static char ctrlconv[] =
337 "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x40\x4b\x4c\x4d\x4e\x4f" 339 "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x40\x4b\x4c\x4d\x4e\x4f"
338 "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"; 340 "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f";
339 341
342#if ENABLE_FEATURE_LESS_REGEXP
340static void print_found(const char *line) 343static void print_found(const char *line)
341{ 344{
342 int match_status; 345 int match_status;
@@ -397,6 +400,9 @@ static void print_found(const char *line)
397 printf(CLEAR_2_EOL"%s%s\n", growline, str); 400 printf(CLEAR_2_EOL"%s%s\n", growline, str);
398 free(growline); 401 free(growline);
399} 402}
403#else
404void print_found(const char *line);
405#endif
400 406
401static void print_ascii(const char *str) 407static void print_ascii(const char *str)
402{ 408{
@@ -718,6 +724,7 @@ static void colon_process(void)
718 } 724 }
719} 725}
720 726
727#if ENABLE_FEATURE_LESS_REGEXP
721static int normalize_match_pos(int match) 728static int normalize_match_pos(int match)
722{ 729{
723 match_pos = match; 730 match_pos = match;
@@ -728,7 +735,6 @@ static int normalize_match_pos(int match)
728 return match_pos; 735 return match_pos;
729} 736}
730 737
731#if ENABLE_FEATURE_LESS_REGEXP
732static void goto_match(int match) 738static void goto_match(int match)
733{ 739{
734 if (num_matches) 740 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 @@
8 8
9#include "busybox.h" 9#include "busybox.h"
10#include <sched.h> 10#include <sched.h>
11#include <unistd.h>
12#include <getopt.h> /* optind */ 11#include <getopt.h> /* optind */
13 12
14#if ENABLE_FEATURE_TASKSET_FANCY 13#if ENABLE_FEATURE_TASKSET_FANCY
15#define TASKSET_PRINTF_MASK "%s" 14#define TASKSET_PRINTF_MASK "%s"
16#define from_cpuset(x) __from_cpuset(&x) 15#define from_cpuset(x) __from_cpuset(&x)
17/* craft a string from the mask */ 16/* craft a string from the mask */
18static char *__from_cpuset(cpu_set_t *mask) { 17static char *__from_cpuset(cpu_set_t *mask)
18{
19 int i; 19 int i;
20 char *ret = 0, *str = xzalloc(9); 20 char *ret = 0, *str = xzalloc(9);
21 21
@@ -34,22 +34,24 @@ static char *__from_cpuset(cpu_set_t *mask) {
34} 34}
35#else 35#else
36#define TASKSET_PRINTF_MASK "%x" 36#define TASKSET_PRINTF_MASK "%x"
37#define from_cpuset(mask) mask 37/* (void*) cast is for battling gcc: */
38/* "dereferencing type-punned pointer will break strict-aliasing rules" */
39#define from_cpuset(mask) (*(unsigned*)(void*)&(mask))
38#endif 40#endif
39 41
40#define TASKSET_OPT_p (1) 42#define OPT_p 1
41 43
42int taskset_main(int argc, char** argv) 44int taskset_main(int argc, char** argv)
43{ 45{
44 cpu_set_t mask, new_mask; 46 cpu_set_t mask, new_mask;
45 pid_t pid = 0; 47 pid_t pid = 0;
46 unsigned long ul; 48 unsigned opt;
47 const char *state = "current\0new"; 49 const char *state = "current\0new";
48 char *p_opt = NULL, *aff = NULL; 50 char *p_opt = NULL, *aff = NULL;
49 51
50 ul = getopt32(argc, argv, "+p:", &p_opt); 52 opt = getopt32(argc, argv, "+p:", &p_opt);
51 53
52 if (ul & TASKSET_OPT_p) { 54 if (opt & OPT_p) {
53 if (argc == optind+1) { /* -p <aff> <pid> */ 55 if (argc == optind+1) { /* -p <aff> <pid> */
54 aff = p_opt; 56 aff = p_opt;
55 p_opt = argv[optind]; 57 p_opt = argv[optind];
@@ -70,19 +72,19 @@ int taskset_main(int argc, char** argv)
70 } 72 }
71 } 73 }
72 74
73 if (ul & TASKSET_OPT_p) { 75 if (opt & OPT_p) {
74print_aff: 76 print_aff:
75 if (sched_getaffinity(pid, sizeof (mask), &mask) < 0) 77 if (sched_getaffinity(pid, sizeof(mask), &mask) < 0)
76 bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 'g', pid); 78 bb_perror_msg_and_die("failed to %cet pid %d's affinity", 'g', pid);
77 printf("pid %d's %s affinity mask: "TASKSET_PRINTF_MASK"\n", 79 printf("pid %d's %s affinity mask: "TASKSET_PRINTF_MASK"\n",
78 pid, state, from_cpuset(mask)); 80 pid, state, from_cpuset(mask));
79 if (!*argv) /* no new affinity given or we did print already, done. */ 81 if (!*argv) /* no new affinity given or we did print already, done. */
80 return EXIT_SUCCESS; 82 return EXIT_SUCCESS;
81 } 83 }
82 84
83 if (sched_setaffinity(pid, sizeof (new_mask), &new_mask)) 85 if (sched_setaffinity(pid, sizeof(new_mask), &new_mask))
84 bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 's', pid); 86 bb_perror_msg_and_die("failed to %cet pid %d's affinity", 's', pid);
85 if (ul & TASKSET_OPT_p) { 87 if (opt & OPT_p) {
86 state += 8; 88 state += 8;
87 ++argv; 89 ++argv;
88 goto print_aff; 90 goto print_aff;
@@ -91,6 +93,6 @@ print_aff:
91 execvp(*argv, argv); 93 execvp(*argv, argv);
92 bb_perror_msg_and_die("%s", *argv); 94 bb_perror_msg_and_die("%s", *argv);
93} 95}
94#undef TASKSET_OPT_p 96#undef OPT_p
95#undef TASKSET_PRINTF_MASK 97#undef TASKSET_PRINTF_MASK
96#undef from_cpuset 98#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 @@
63#include <sys/utsname.h> 63#include <sys/utsname.h>
64 64
65#if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES 65#if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES
66#undef ENABLE_FEATURE_2_4_MODULES
66#define ENABLE_FEATURE_2_4_MODULES 1 67#define ENABLE_FEATURE_2_4_MODULES 1
67#endif 68#endif
68 69
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)
338 return 0; 338 return 0;
339} 339}
340 340
341#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES 341#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
342 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
343 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
342static void free_config_lines(Htaccess **pprev) 344static void free_config_lines(Htaccess **pprev)
343{ 345{
344 Htaccess *prev = *pprev; 346 Htaccess *prev = *pprev;
@@ -387,8 +389,11 @@ static void parse_conf(const char *path, int flag)
387{ 389{
388 FILE *f; 390 FILE *f;
389#if ENABLE_FEATURE_HTTPD_BASIC_AUTH 391#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
390 Htaccess *prev, *cur; 392 Htaccess *prev;
391#elif ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES 393#endif
394#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
395 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
396 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
392 Htaccess *cur; 397 Htaccess *cur;
393#endif 398#endif
394 399
@@ -410,7 +415,9 @@ static void parse_conf(const char *path, int flag)
410 415
411 config->flg_deny_all = 0; 416 config->flg_deny_all = 0;
412 417
413#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 418#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
419 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
420 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
414 /* retain previous auth and mime config only for subdir parse */ 421 /* retain previous auth and mime config only for subdir parse */
415 if (flag != SUBDIR_PARSE) { 422 if (flag != SUBDIR_PARSE) {
416#if ENABLE_FEATURE_HTTPD_BASIC_AUTH 423#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
@@ -559,7 +566,9 @@ static void parse_conf(const char *path, int flag)
559 } 566 }
560#endif 567#endif
561 568
562#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 569#if ENABLE_FEATURE_HTTPD_BASIC_AUTH \
570 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \
571 || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
563 /* storing current config line */ 572 /* storing current config line */
564 cur = calloc(1, sizeof(Htaccess) + strlen(p0)); 573 cur = calloc(1, sizeof(Htaccess) + strlen(p0));
565 if (cur) { 574 if (cur) {
@@ -1305,8 +1314,9 @@ static int checkPermIP(void)
1305 1314
1306 /* This could stand some work */ 1315 /* This could stand some work */
1307 for (cur = config->ip_a_d; cur; cur = cur->next) { 1316 for (cur = config->ip_a_d; cur; cur = cur->next) {
1308 if (DEBUG) 1317#if DEBUG
1309 fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str); 1318 fprintf(stderr, "checkPermIP: '%s' ? ", config->rmt_ip_str);
1319#endif
1310 if (DEBUG) 1320 if (DEBUG)
1311 fprintf(stderr, "'%u.%u.%u.%u/%u.%u.%u.%u'\n", 1321 fprintf(stderr, "'%u.%u.%u.%u/%u.%u.%u.%u'\n",
1312 (unsigned char)(cur->ip >> 24), 1322 (unsigned char)(cur->ip >> 24),
@@ -1589,7 +1599,8 @@ static void handleIncoming(void)
1589 /* extra read only for POST */ 1599 /* extra read only for POST */
1590 if (prequest != request_GET) { 1600 if (prequest != request_GET) {
1591 test = buf + sizeof("Content-length:")-1; 1601 test = buf + sizeof("Content-length:")-1;
1592 if (!test[0]) goto bail_out; 1602 if (!test[0])
1603 goto bail_out;
1593 errno = 0; 1604 errno = 0;
1594 /* not using strtoul: it ignores leading munis! */ 1605 /* not using strtoul: it ignores leading munis! */
1595 length = strtol(test, &test, 10); 1606 length = strtol(test, &test, 10);
@@ -1690,7 +1701,9 @@ static void handleIncoming(void)
1690 config->ContentLength = -1; 1701 config->ContentLength = -1;
1691 } while (0); 1702 } while (0);
1692 1703
1704#if ENABLE_FEATURE_HTTPD_CGI
1693 bail_out: 1705 bail_out:
1706#endif
1694 1707
1695 if (DEBUG) 1708 if (DEBUG)
1696 fprintf(stderr, "closing socket\n\n"); 1709 fprintf(stderr, "closing socket\n\n");
@@ -1910,20 +1923,9 @@ int httpd_main(int argc, char *argv[])
1910 1923
1911#if ENABLE_FEATURE_HTTPD_SETUID 1924#if ENABLE_FEATURE_HTTPD_SETUID
1912 if (opt & OPT_SETUID) { 1925 if (opt & OPT_SETUID) {
1913 char *e; 1926 if (!get_uidgid(&ugid, s_ugid, 1))
1914 // FIXME: what the default group should be? 1927 bb_error_msg_and_die("unrecognized user[:group] "
1915 ugid.gid = -1;
1916 ugid.uid = bb_strtoul(s_ugid, &e, 0);
1917 if (*e == ':') {
1918 e++;
1919 ugid.gid = bb_strtoul(e, NULL, 0);
1920 }
1921 if (errno) {
1922 /* not integer */
1923 if (!uidgid_get(&ugid, s_ugid))
1924 bb_error_msg_and_die("unrecognized user[:group] "
1925 "name '%s'", s_ugid); 1928 "name '%s'", s_ugid);
1926 }
1927 } 1929 }
1928#endif 1930#endif
1929 1931
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 {
50 unsigned long ticks; 50 unsigned long ticks;
51 unsigned pid; 51 unsigned pid;
52}; 52};
53#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
53static struct save_hist *prev_hist; 54static struct save_hist *prev_hist;
54static int prev_hist_count; 55static int prev_hist_count;
55/* static int hist_iterations; */ 56/* static int hist_iterations; */
56static unsigned total_pcpu; 57static unsigned total_pcpu;
57/* static unsigned long total_rss; */ 58/* static unsigned long total_rss; */
58 59#endif
59 60
60#define OPT_BATCH_MODE (option_mask32 & 0x4) 61#define OPT_BATCH_MODE (option_mask32 & 0x4)
61 62
@@ -485,7 +486,9 @@ int top_main(int argc, char **argv)
485 top[n].pid = p->pid; 486 top[n].pid = p->pid;
486 top[n].ppid = p->ppid; 487 top[n].ppid = p->ppid;
487 top[n].rss = p->rss; 488 top[n].rss = p->rss;
489#if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
488 top[n].ticks = p->stime + p->utime; 490 top[n].ticks = p->stime + p->utime;
491#endif
489 top[n].uid = p->uid; 492 top[n].uid = p->uid;
490 strcpy(top[n].state, p->state); 493 strcpy(top[n].state, p->state);
491 strcpy(top[n].comm, p->comm); 494 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
10lib-$(CONFIG_SV) += sv.o runit_lib.o 10lib-$(CONFIG_SV) += sv.o runit_lib.o
11lib-$(CONFIG_SVLOGD) += svlogd.o runit_lib.o 11lib-$(CONFIG_SVLOGD) += svlogd.o runit_lib.o
12lib-$(CONFIG_CHPST) += chpst.o 12lib-$(CONFIG_CHPST) += chpst.o
13
14lib-$(CONFIG_ENVDIR) += chpst.o
15lib-$(CONFIG_ENVUIDGID) += chpst.o
16lib-$(CONFIG_SETUIDGID) += chpst.o
17lib-$(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)
2797{ 2797{
2798 char *str_b, *str_C, *str_H, *str_S; 2798 char *str_b, *str_C, *str_H, *str_S;
2799 unsigned opt; 2799 unsigned opt;
2800 int c;
2801 /* 2800 /*
2802 * fdisk -v 2801 * fdisk -v
2803 * fdisk -l [-b sectorsize] [-u] device ... 2802 * fdisk -l [-b sectorsize] [-u] device ...
@@ -2921,6 +2920,7 @@ int fdisk_main(int argc, char **argv)
2921 } 2920 }
2922 2921
2923 while (1) { 2922 while (1) {
2923 int c;
2924 putchar('\n'); 2924 putchar('\n');
2925 c = tolower(read_nonempty(_("Command (m for help): "))); 2925 c = tolower(read_nonempty(_("Command (m for help): ")));
2926 switch (c) { 2926 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)
453 if (dind) 453 if (dind)
454 write_block(dind, (char *) dind_block); 454 write_block(dind, (char *) dind_block);
455} 455}
456#else
457void make_bad_inode2(void);
456#endif 458#endif
457 459
458static void make_root_inode(void) 460static void make_root_inode(void)
@@ -499,6 +501,8 @@ static void make_root_inode2(void)
499 inode->i_gid = GETGID; 501 inode->i_gid = GETGID;
500 write_block(inode->i_zone[0], root_block); 502 write_block(inode->i_zone[0], root_block);
501} 503}
504#else
505void make_root_inode2(void);
502#endif 506#endif
503 507
504static void setup_tables(void) 508static void setup_tables(void)