aboutsummaryrefslogtreecommitdiff
path: root/util-linux/hwclock.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-09 19:10:49 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-09 19:10:49 +0100
commitdc698bb038756a926aaa529bda1b939eab2c1676 (patch)
tree4084a40897d9d81816228935a1398e80dd4b173b /util-linux/hwclock.c
parent0681137972dc89b5003b0415e09184c0ecf1c875 (diff)
downloadbusybox-w32-dc698bb038756a926aaa529bda1b939eab2c1676.tar.gz
busybox-w32-dc698bb038756a926aaa529bda1b939eab2c1676.tar.bz2
busybox-w32-dc698bb038756a926aaa529bda1b939eab2c1676.zip
*: make it easier to distinquish "struct tm", pointer to one, etc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/hwclock.c')
-rw-r--r--util-linux/hwclock.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index ac89d45a2..b8300570e 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -37,20 +37,20 @@
37#endif 37#endif
38static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc) 38static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc)
39{ 39{
40 struct tm tm; 40 struct tm tm_time;
41 int fd; 41 int fd;
42 42
43 fd = rtc_xopen(pp_rtcname, O_RDONLY); 43 fd = rtc_xopen(pp_rtcname, O_RDONLY);
44 44
45 rtc_read_tm(&tm, fd); 45 rtc_read_tm(&tm_time, fd);
46 46
47#if SHOW_HWCLOCK_DIFF 47#if SHOW_HWCLOCK_DIFF
48 { 48 {
49 int before = tm.tm_sec; 49 int before = tm_time.tm_sec;
50 while (1) { 50 while (1) {
51 rtc_read_tm(&tm, fd); 51 rtc_read_tm(&tm_time, fd);
52 gettimeofday(sys_tv, NULL); 52 gettimeofday(sys_tv, NULL);
53 if (before != tm.tm_sec) 53 if (before != tm_time.tm_sec)
54 break; 54 break;
55 } 55 }
56 } 56 }
@@ -59,7 +59,7 @@ static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc)
59 if (ENABLE_FEATURE_CLEAN_UP) 59 if (ENABLE_FEATURE_CLEAN_UP)
60 close(fd); 60 close(fd);
61 61
62 return rtc_tm2time(&tm, utc); 62 return rtc_tm2time(&tm_time, utc);
63} 63}
64 64
65static void show_clock(const char **pp_rtcname, int utc) 65static void show_clock(const char **pp_rtcname, int utc)
@@ -110,7 +110,7 @@ static void to_sys_clock(const char **pp_rtcname, int utc)
110static void from_sys_clock(const char **pp_rtcname, int utc) 110static void from_sys_clock(const char **pp_rtcname, int utc)
111{ 111{
112#define TWEAK_USEC 200 112#define TWEAK_USEC 200
113 struct tm tm; 113 struct tm tm_time;
114 struct timeval tv; 114 struct timeval tv;
115 unsigned adj = TWEAK_USEC; 115 unsigned adj = TWEAK_USEC;
116 int rtc = rtc_xopen(pp_rtcname, O_WRONLY); 116 int rtc = rtc_xopen(pp_rtcname, O_WRONLY);
@@ -132,10 +132,10 @@ static void from_sys_clock(const char **pp_rtcname, int utc)
132 132
133 /* Prepare tm */ 133 /* Prepare tm */
134 if (utc) 134 if (utc)
135 gmtime_r(&t, &tm); /* may read /etc/xxx (it takes time) */ 135 gmtime_r(&t, &tm_time); /* may read /etc/xxx (it takes time) */
136 else 136 else
137 localtime_r(&t, &tm); /* same */ 137 localtime_r(&t, &tm_time); /* same */
138 tm.tm_isdst = 0; 138 tm_time.tm_isdst = 0;
139 139
140 /* gmtime/localtime took some time, re-get cur time */ 140 /* gmtime/localtime took some time, re-get cur time */
141 gettimeofday(&tv, NULL); 141 gettimeofday(&tv, NULL);
@@ -166,7 +166,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc)
166 usleep(rem_usec - adj); 166 usleep(rem_usec - adj);
167 } 167 }
168 168
169 xioctl(rtc, RTC_SET_TIME, &tm); 169 xioctl(rtc, RTC_SET_TIME, &tm_time);
170 170
171 /* Debug aid to find "good" TWEAK_USEC. 171 /* Debug aid to find "good" TWEAK_USEC.
172 * Look for a value which makes tv_usec close to 999999 or 0. 172 * Look for a value which makes tv_usec close to 999999 or 0.