diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-30 17:57:03 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-30 17:57:03 +0000 |
commit | 3bba545a54addf59b63a003e7ada03fd8b29b5ba (patch) | |
tree | 948ce196f871abcf9410ca1521a3d2a5af6a3082 /miscutils | |
parent | b5a122b6f9643fb052d31390e435397960289154 (diff) | |
download | busybox-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
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/less.c | 10 | ||||
-rw-r--r-- | miscutils/taskset.c | 32 |
2 files changed, 25 insertions, 17 deletions
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! */ | |||
109 | static unsigned num_matches; | 109 | static unsigned num_matches; |
110 | static regex_t pattern; | 110 | static regex_t pattern; |
111 | static unsigned pattern_valid; | 111 | static unsigned pattern_valid; |
112 | #else | ||
113 | enum { pattern_valid = 0 }; | ||
112 | #endif | 114 | #endif |
113 | 115 | ||
114 | static struct termios term_orig, term_vi; | 116 | static 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 | ||
340 | static void print_found(const char *line) | 343 | static 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 | ||
404 | void print_found(const char *line); | ||
405 | #endif | ||
400 | 406 | ||
401 | static void print_ascii(const char *str) | 407 | static 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 | ||
721 | static int normalize_match_pos(int match) | 728 | static 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 | ||
732 | static void goto_match(int match) | 738 | static 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 */ |
18 | static char *__from_cpuset(cpu_set_t *mask) { | 17 | static 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 | ||
42 | int taskset_main(int argc, char** argv) | 44 | int 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) { |
74 | print_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 |