mkfs_ext2: fix bad comment. no code changes
[oweals/busybox.git] / util-linux / rtcwake.c
index f90f73cedbbd925da1176f5cfa65ac8b0e35cce2..66b08e34393090497df3785614bcd77254af435e 100644 (file)
@@ -50,7 +50,7 @@ static NOINLINE bool may_wakeup(const char *rtcname)
 
 static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time)
 {
-       struct tm *tm;
+       struct tm *ptm;
        struct linux_rtc_wkalrm wake;
 
        /* The wakeup time is in POSIX time (more or less UTC).
@@ -63,14 +63,14 @@ static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time)
         * Else mode is local so the time given to the RTC
         * will instead use the local time zone.
         */
-       tm = localtime(wakeup);
-
-       wake.time.tm_sec = tm->tm_sec;
-       wake.time.tm_min = tm->tm_min;
-       wake.time.tm_hour = tm->tm_hour;
-       wake.time.tm_mday = tm->tm_mday;
-       wake.time.tm_mon = tm->tm_mon;
-       wake.time.tm_year = tm->tm_year;
+       ptm = localtime(wakeup);
+
+       wake.time.tm_sec = ptm->tm_sec;
+       wake.time.tm_min = ptm->tm_min;
+       wake.time.tm_hour = ptm->tm_hour;
+       wake.time.tm_mday = ptm->tm_mday;
+       wake.time.tm_mon = ptm->tm_mon;
+       wake.time.tm_year = ptm->tm_year;
        /* wday, yday, and isdst fields are unused by Linux */
        wake.time.tm_wday = -1;
        wake.time.tm_yday = -1;
@@ -160,7 +160,12 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
 
        /* relative or absolute alarm time, normalized to time_t */
        sys_time = time(NULL);
-       rtc_time = rtc_read_time(fd, utc);
+       {
+               struct tm tm_time;
+               rtc_read_tm(&tm_time, fd);
+               rtc_time = rtc_tm2time(&tm_time, utc);
+       }
+
 
        if (alarm_time) {
                if (alarm_time < sys_time)
@@ -172,7 +177,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
 
        sync();
        printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time));
-       fflush(NULL);
+       fflush_all();
        usleep(10 * 1000);
 
        if (strcmp(suspend, "on"))