diff options
author | Denis Vlasenko | 2006-12-30 17:57:03 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-12-30 17:57:03 +0000 |
commit | 3bba545a54addf59b63a003e7ada03fd8b29b5ba (patch) | |
tree | 948ce196f871abcf9410ca1521a3d2a5af6a3082 /miscutils | |
parent | b5a122b6f9643fb052d31390e435397960289154 (diff) | |
download | busybox-3bba545a54addf59b63a003e7ada03fd8b29b5ba.zip busybox-3bba545a54addf59b63a003e7ada03fd8b29b5ba.tar.gz |
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 60c54e6..807a5bf 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 4496aa5..a4d41ac 100644 --- a/miscutils/taskset.c +++ b/miscutils/taskset.c @@ -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 |