diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-29 13:27:31 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-29 13:27:31 +0100 |
| commit | 85ca327529afeceed41c1d66d0b7d48c2ffc2a4b (patch) | |
| tree | addba6c780c2d0318f7091afb80e9be90f900ad0 | |
| parent | 1f6d2307bafd1e55addac5fc28a71f59fc3bd5ba (diff) | |
| download | busybox-w32-85ca327529afeceed41c1d66d0b7d48c2ffc2a4b.tar.gz busybox-w32-85ca327529afeceed41c1d66d0b7d48c2ffc2a4b.tar.bz2 busybox-w32-85ca327529afeceed41c1d66d0b7d48c2ffc2a4b.zip | |
*: random code shrink
function old new delta
alarm_handler 50 46 -4
ask 228 211 -17
rtcwake_main 474 455 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | loginutils/login.c | 2 | ||||
| -rw-r--r-- | util-linux/fsck_minix.c | 14 | ||||
| -rw-r--r-- | util-linux/rtcwake.c | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/loginutils/login.c b/loginutils/login.c index 70e85625b..c3e31d05d 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
| @@ -263,7 +263,7 @@ static void alarm_handler(int sig UNUSED_PARAM) | |||
| 263 | * We don't want to block here */ | 263 | * We don't want to block here */ |
| 264 | ndelay_on(1); | 264 | ndelay_on(1); |
| 265 | printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT); | 265 | printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT); |
| 266 | fflush(stdout); | 266 | fflush(NULL); |
| 267 | /* unix API is brain damaged regarding O_NONBLOCK, | 267 | /* unix API is brain damaged regarding O_NONBLOCK, |
| 268 | * we should undo it, or else we can affect other processes */ | 268 | * we should undo it, or else we can affect other processes */ |
| 269 | ndelay_off(1); | 269 | ndelay_off(1); |
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 5d1d2af31..cdd306031 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c | |||
| @@ -341,22 +341,24 @@ static int ask(const char *string, int def) | |||
| 341 | } | 341 | } |
| 342 | printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); | 342 | printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); |
| 343 | for (;;) { | 343 | for (;;) { |
| 344 | fflush(stdout); | 344 | fflush(NULL); |
| 345 | c = getchar(); | 345 | c = getchar(); |
| 346 | if (c == EOF) { | 346 | if (c == EOF) { |
| 347 | if (!def) | 347 | if (!def) |
| 348 | errors_uncorrected = 1; | 348 | errors_uncorrected = 1; |
| 349 | return def; | 349 | return def; |
| 350 | } | 350 | } |
| 351 | c = toupper(c); | 351 | if (c == '\n') |
| 352 | if (c == 'Y') { | 352 | break; |
| 353 | c |= 0x20; /* tolower */ | ||
| 354 | if (c == 'y') { | ||
| 353 | def = 1; | 355 | def = 1; |
| 354 | break; | 356 | break; |
| 355 | } else if (c == 'N') { | 357 | } |
| 358 | if (c == 'n') { | ||
| 356 | def = 0; | 359 | def = 0; |
| 357 | break; | 360 | break; |
| 358 | } else if (c == ' ' || c == '\n') | 361 | } |
| 359 | break; | ||
| 360 | } | 362 | } |
| 361 | if (def) | 363 | if (def) |
| 362 | printf("y\n"); | 364 | printf("y\n"); |
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c index 4d2be00f5..f90f73ced 100644 --- a/util-linux/rtcwake.c +++ b/util-linux/rtcwake.c | |||
| @@ -141,7 +141,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
| 141 | seconds = xatoi(opt_seconds); | 141 | seconds = xatoi(opt_seconds); |
| 142 | if (opt & RTCWAKE_OPT_TIME) | 142 | if (opt & RTCWAKE_OPT_TIME) |
| 143 | /* alarm time, time_t (absolute, seconds since 1/1 1970 UTC) */ | 143 | /* alarm time, time_t (absolute, seconds since 1/1 1970 UTC) */ |
| 144 | alarm_time = xatoi(opt_time); | 144 | alarm_time = xatol(opt_time); |
| 145 | 145 | ||
| 146 | if (!alarm_time && !seconds) | 146 | if (!alarm_time && !seconds) |
| 147 | bb_error_msg_and_die("must provide wake time"); | 147 | bb_error_msg_and_die("must provide wake time"); |
| @@ -160,8 +160,6 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
| 160 | 160 | ||
| 161 | /* relative or absolute alarm time, normalized to time_t */ | 161 | /* relative or absolute alarm time, normalized to time_t */ |
| 162 | sys_time = time(NULL); | 162 | sys_time = time(NULL); |
| 163 | if (sys_time == (time_t)-1) | ||
| 164 | bb_perror_msg_and_die("read system time"); | ||
| 165 | rtc_time = rtc_read_time(fd, utc); | 163 | rtc_time = rtc_read_time(fd, utc); |
| 166 | 164 | ||
| 167 | if (alarm_time) { | 165 | if (alarm_time) { |
| @@ -174,7 +172,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
| 174 | 172 | ||
| 175 | sync(); | 173 | sync(); |
| 176 | printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time)); | 174 | printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time)); |
| 177 | fflush(stdout); | 175 | fflush(NULL); |
| 178 | usleep(10 * 1000); | 176 | usleep(10 * 1000); |
| 179 | 177 | ||
| 180 | if (strcmp(suspend, "on")) | 178 | if (strcmp(suspend, "on")) |
