summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2009-10-29 13:27:31 +0100
committerDenys Vlasenko2009-10-29 13:27:31 +0100
commit85ca327529afeceed41c1d66d0b7d48c2ffc2a4b (patch)
treeaddba6c780c2d0318f7091afb80e9be90f900ad0
parent1f6d2307bafd1e55addac5fc28a71f59fc3bd5ba (diff)
downloadbusybox-85ca327529afeceed41c1d66d0b7d48c2ffc2a4b.zip
busybox-85ca327529afeceed41c1d66d0b7d48c2ffc2a4b.tar.gz
*: 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.c2
-rw-r--r--util-linux/fsck_minix.c14
-rw-r--r--util-linux/rtcwake.c6
3 files changed, 11 insertions, 11 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 70e8562..c3e31d0 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -263,7 +263,7 @@ static void alarm_handler(int sig UNUSED_PARAM)
* We don't want to block here */
ndelay_on(1);
printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT);
- fflush(stdout);
+ fflush(NULL);
/* unix API is brain damaged regarding O_NONBLOCK,
* we should undo it, or else we can affect other processes */
ndelay_off(1);
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 5d1d2af..cdd3060 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)
}
printf(def ? "%s (y/n)? " : "%s (n/y)? ", string);
for (;;) {
- fflush(stdout);
+ fflush(NULL);
c = getchar();
if (c == EOF) {
if (!def)
errors_uncorrected = 1;
return def;
}
- c = toupper(c);
- if (c == 'Y') {
+ if (c == '\n')
+ break;
+ c |= 0x20; /* tolower */
+ if (c == 'y') {
def = 1;
break;
- } else if (c == 'N') {
+ }
+ if (c == 'n') {
def = 0;
break;
- } else if (c == ' ' || c == '\n')
- break;
+ }
}
if (def)
printf("y\n");
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c
index 4d2be00..f90f73c 100644
--- a/util-linux/rtcwake.c
+++ b/util-linux/rtcwake.c
@@ -141,7 +141,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
seconds = xatoi(opt_seconds);
if (opt & RTCWAKE_OPT_TIME)
/* alarm time, time_t (absolute, seconds since 1/1 1970 UTC) */
- alarm_time = xatoi(opt_time);
+ alarm_time = xatol(opt_time);
if (!alarm_time && !seconds)
bb_error_msg_and_die("must provide wake time");
@@ -160,8 +160,6 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
/* relative or absolute alarm time, normalized to time_t */
sys_time = time(NULL);
- if (sys_time == (time_t)-1)
- bb_perror_msg_and_die("read system time");
rtc_time = rtc_read_time(fd, utc);
if (alarm_time) {
@@ -174,7 +172,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
sync();
printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time));
- fflush(stdout);
+ fflush(NULL);
usleep(10 * 1000);
if (strcmp(suspend, "on"))