]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rtcwake: clean up struct tm initializations
authorSami Kerola <kerolasa@iki.fi>
Sat, 10 Jan 2015 19:13:11 +0000 (19:13 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 29 Jun 2015 11:39:37 +0000 (13:39 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/rtcwake.c

index 2fcb5ffa7172f149d214db54f91ded3e842f2024..31c1eee6e7b2657a7bd0c6af5a00aea6e066c2a8 100644 (file)
@@ -160,7 +160,7 @@ static int is_wakeup_enabled(const char *devname)
 
 static int get_basetimes(struct rtcwake_control *ctl, int fd)
 {
-       struct tm       tm;
+       struct tm       tm = { 0 };
        struct rtc_time rtc;
 
        /* this process works in RTC time, except when working
@@ -186,7 +186,6 @@ static int get_basetimes(struct rtcwake_control *ctl, int fd)
        /* convert rtc_time to normal arithmetic-friendly form,
         * updating tm.tm_wday as used by asctime().
         */
-       memset(&tm, 0, sizeof tm);
        tm.tm_sec = rtc.tm_sec;
        tm.tm_min = rtc.tm_min;
        tm.tm_hour = rtc.tm_hour;
@@ -334,8 +333,7 @@ static int read_clock_mode(struct rtcwake_control *ctl)
 static int print_alarm(struct rtcwake_control *ctl, int fd)
 {
        struct rtc_wkalrm wake;
-       struct rtc_time rtc;
-       struct tm tm;
+       struct tm tm = { 0 };
        time_t alarm;
 
        if (ioctl(fd, RTC_WKALM_RD, &wake) < 0) {
@@ -348,15 +346,12 @@ static int print_alarm(struct rtcwake_control *ctl, int fd)
                return 0;
        }
 
-       rtc = wake.time;
-
-       memset(&tm, 0, sizeof tm);
-       tm.tm_sec = rtc.tm_sec;
-       tm.tm_min = rtc.tm_min;
-       tm.tm_hour = rtc.tm_hour;
-       tm.tm_mday = rtc.tm_mday;
-       tm.tm_mon = rtc.tm_mon;
-       tm.tm_year = rtc.tm_year;
+       tm.tm_sec = wake.time.tm_sec;
+       tm.tm_min = wake.time.tm_min;
+       tm.tm_hour = wake.time.tm_hour;
+       tm.tm_mday = wake.time.tm_mday;
+       tm.tm_mon = wake.time.tm_mon;
+       tm.tm_year = wake.time.tm_year;
        tm.tm_isdst = -1;  /* assume the system knows better than the RTC */
 
        alarm = mktime(&tm);