summaryrefslogtreecommitdiffstats
path: root/sys-utils/rtcwake.c
diff options
context:
space:
mode:
authorSami Kerola2015-01-10 20:13:11 +0100
committerKarel Zak2015-06-29 13:39:37 +0200
commit499a0c795614306d605c2abc78f73282be2a6352 (patch)
tree5bffe466e56af9bc877519e66bbdc7c76b025d28 /sys-utils/rtcwake.c
parentrtcwake: fix preprocessor redefinition (diff)
downloadkernel-qcow2-util-linux-499a0c795614306d605c2abc78f73282be2a6352.tar.gz
kernel-qcow2-util-linux-499a0c795614306d605c2abc78f73282be2a6352.tar.xz
kernel-qcow2-util-linux-499a0c795614306d605c2abc78f73282be2a6352.zip
rtcwake: clean up struct tm initializations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r--sys-utils/rtcwake.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 2fcb5ffa7..31c1eee6e 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -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);