aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--archival/libunarchive/header_verbose_list.c34
-rw-r--r--archival/rpm.c6
-rw-r--r--coreutils/cal.c9
-rw-r--r--include/libbb.h4
-rw-r--r--include/rtc_.h4
-rw-r--r--libbb/rtc.c12
-rw-r--r--libbb/time.c90
-rw-r--r--miscutils/crond.c10
-rw-r--r--networking/httpd_indexcgi.c14
-rw-r--r--runit/svlogd.c16
-rw-r--r--util-linux/hwclock.c22
-rw-r--r--util-linux/mkfs_vfat.c8
-rw-r--r--util-linux/rtcwake.c24
13 files changed, 131 insertions, 122 deletions
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c
index da21a15af..f6f04cfd5 100644
--- a/archival/libunarchive/header_verbose_list.c
+++ b/archival/libunarchive/header_verbose_list.c
@@ -8,7 +8,8 @@
8 8
9void FAST_FUNC header_verbose_list(const file_header_t *file_header) 9void FAST_FUNC header_verbose_list(const file_header_t *file_header)
10{ 10{
11 struct tm *mtime = localtime(&(file_header->mtime)); 11 struct tm tm_time;
12 struct tm *ptm = &tm_time; //localtime(&file_header->mtime);
12 13
13#if ENABLE_FEATURE_TAR_UNAME_GNAME 14#if ENABLE_FEATURE_TAR_UNAME_GNAME
14 char uid[sizeof(int)*3 + 2]; 15 char uid[sizeof(int)*3 + 2];
@@ -16,6 +17,8 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
16 char *user; 17 char *user;
17 char *group; 18 char *group;
18 19
20 localtime_r(&file_header->mtime, ptm);
21
19 user = file_header->tar__uname; 22 user = file_header->tar__uname;
20 if (user == NULL) { 23 if (user == NULL) {
21 sprintf(uid, "%u", (unsigned)file_header->uid); 24 sprintf(uid, "%u", (unsigned)file_header->uid);
@@ -31,26 +34,31 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
31 user, 34 user,
32 group, 35 group,
33 file_header->size, 36 file_header->size,
34 1900 + mtime->tm_year, 37 1900 + ptm->tm_year,
35 1 + mtime->tm_mon, 38 1 + ptm->tm_mon,
36 mtime->tm_mday, 39 ptm->tm_mday,
37 mtime->tm_hour, 40 ptm->tm_hour,
38 mtime->tm_min, 41 ptm->tm_min,
39 mtime->tm_sec, 42 ptm->tm_sec,
40 file_header->name); 43 file_header->name);
44
41#else /* !FEATURE_TAR_UNAME_GNAME */ 45#else /* !FEATURE_TAR_UNAME_GNAME */
46
47 localtime_r(&file_header->mtime, ptm);
48
42 printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s", 49 printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
43 bb_mode_string(file_header->mode), 50 bb_mode_string(file_header->mode),
44 (unsigned)file_header->uid, 51 (unsigned)file_header->uid,
45 (unsigned)file_header->gid, 52 (unsigned)file_header->gid,
46 file_header->size, 53 file_header->size,
47 1900 + mtime->tm_year, 54 1900 + ptm->tm_year,
48 1 + mtime->tm_mon, 55 1 + ptm->tm_mon,
49 mtime->tm_mday, 56 ptm->tm_mday,
50 mtime->tm_hour, 57 ptm->tm_hour,
51 mtime->tm_min, 58 ptm->tm_min,
52 mtime->tm_sec, 59 ptm->tm_sec,
53 file_header->name); 60 file_header->name);
61
54#endif /* FEATURE_TAR_UNAME_GNAME */ 62#endif /* FEATURE_TAR_UNAME_GNAME */
55 63
56 if (file_header->link_target) { 64 if (file_header->link_target) {
diff --git a/archival/rpm.c b/archival/rpm.c
index cdaf50fa9..6c1e341cd 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -145,13 +145,13 @@ int rpm_main(int argc, char **argv)
145 if (func & rpm_query_info) { 145 if (func & rpm_query_info) {
146 /* Do the nice printout */ 146 /* Do the nice printout */
147 time_t bdate_time; 147 time_t bdate_time;
148 struct tm *bdate; 148 struct tm *bdate_ptm;
149 char bdatestring[50]; 149 char bdatestring[50];
150 printf("Name : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_PREFIXS, 0) ? rpm_getstr(TAG_PREFIXS, 0) : "(not relocateable)"); 150 printf("Name : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_PREFIXS, 0) ? rpm_getstr(TAG_PREFIXS, 0) : "(not relocateable)");
151 printf("Version : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_VENDOR, 0) ? rpm_getstr(TAG_VENDOR, 0) : "(none)"); 151 printf("Version : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_VENDOR, 0) ? rpm_getstr(TAG_VENDOR, 0) : "(none)");
152 bdate_time = rpm_getint(TAG_BUILDTIME, 0); 152 bdate_time = rpm_getint(TAG_BUILDTIME, 0);
153 bdate = localtime((time_t *) &bdate_time); 153 bdate_ptm = localtime(&bdate_time);
154 strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate); 154 strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm);
155 printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring); 155 printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring);
156 printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0)); 156 printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0));
157 printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), rpm_getstr(TAG_SOURCERPM, 0)); 157 printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), rpm_getstr(TAG_SOURCERPM, 0));
diff --git a/coreutils/cal.c b/coreutils/cal.c
index 823644226..e6f9af937 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -79,7 +79,6 @@ static char *build_row(char *p, unsigned *dp);
79int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 79int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
80int cal_main(int argc UNUSED_PARAM, char **argv) 80int cal_main(int argc UNUSED_PARAM, char **argv)
81{ 81{
82 struct tm *local_time;
83 struct tm zero_tm; 82 struct tm zero_tm;
84 time_t now; 83 time_t now;
85 unsigned month, year, flags, i; 84 unsigned month, year, flags, i;
@@ -94,11 +93,13 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
94 argv += optind; 93 argv += optind;
95 94
96 if (!argv[0]) { 95 if (!argv[0]) {
96 struct tm *ptm;
97
97 time(&now); 98 time(&now);
98 local_time = localtime(&now); 99 ptm = localtime(&now);
99 year = local_time->tm_year + 1900; 100 year = ptm->tm_year + 1900;
100 if (!(flags & 2)) { /* no -y */ 101 if (!(flags & 2)) { /* no -y */
101 month = local_time->tm_mon + 1; 102 month = ptm->tm_mon + 1;
102 } 103 }
103 } else { 104 } else {
104 if (argv[1]) { 105 if (argv[1]) {
diff --git a/include/libbb.h b/include/libbb.h
index cda59dc1f..e07bb52f6 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -444,8 +444,8 @@ struct BUG_too_small {
444}; 444};
445 445
446 446
447void parse_datestr(const char *date_str, struct tm *tm_time) FAST_FUNC; 447void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC;
448time_t validate_tm_time(const char *date_str, struct tm *tm_time) FAST_FUNC; 448time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC;
449 449
450 450
451int xsocket(int domain, int type, int protocol) FAST_FUNC; 451int xsocket(int domain, int type, int protocol) FAST_FUNC;
diff --git a/include/rtc_.h b/include/rtc_.h
index 2b4ae778d..b5fe8ec32 100644
--- a/include/rtc_.h
+++ b/include/rtc_.h
@@ -13,8 +13,8 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
13 13
14int rtc_adjtime_is_utc(void) FAST_FUNC; 14int rtc_adjtime_is_utc(void) FAST_FUNC;
15int rtc_xopen(const char **default_rtc, int flags) FAST_FUNC; 15int rtc_xopen(const char **default_rtc, int flags) FAST_FUNC;
16void rtc_read_tm(struct tm *tm, int fd) FAST_FUNC; 16void rtc_read_tm(struct tm *ptm, int fd) FAST_FUNC;
17time_t rtc_tm2time(struct tm *tm, int utc) FAST_FUNC; 17time_t rtc_tm2time(struct tm *ptm, int utc) FAST_FUNC;
18 18
19 19
20/* 20/*
diff --git a/libbb/rtc.c b/libbb/rtc.c
index 9807e1cf9..fcd6c64d7 100644
--- a/libbb/rtc.c
+++ b/libbb/rtc.c
@@ -59,14 +59,14 @@ int FAST_FUNC rtc_xopen(const char **default_rtc, int flags)
59 return xopen(*default_rtc, flags); 59 return xopen(*default_rtc, flags);
60} 60}
61 61
62void FAST_FUNC rtc_read_tm(struct tm *tm, int fd) 62void FAST_FUNC rtc_read_tm(struct tm *ptm, int fd)
63{ 63{
64 memset(tm, 0, sizeof(*tm)); 64 memset(ptm, 0, sizeof(*ptm));
65 xioctl(fd, RTC_RD_TIME, tm); 65 xioctl(fd, RTC_RD_TIME, ptm);
66 tm->tm_isdst = -1; /* "not known" */ 66 ptm->tm_isdst = -1; /* "not known" */
67} 67}
68 68
69time_t FAST_FUNC rtc_tm2time(struct tm *tm, int utc) 69time_t FAST_FUNC rtc_tm2time(struct tm *ptm, int utc)
70{ 70{
71 char *oldtz = oldtz; /* for compiler */ 71 char *oldtz = oldtz; /* for compiler */
72 time_t t; 72 time_t t;
@@ -77,7 +77,7 @@ time_t FAST_FUNC rtc_tm2time(struct tm *tm, int utc)
77 tzset(); 77 tzset();
78 } 78 }
79 79
80 t = mktime(tm); 80 t = mktime(ptm);
81 81
82 if (utc) { 82 if (utc) {
83 unsetenv("TZ"); 83 unsetenv("TZ");
diff --git a/libbb/time.c b/libbb/time.c
index 85c72d163..82a0fa1fa 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -8,51 +8,51 @@
8 */ 8 */
9#include "libbb.h" 9#include "libbb.h"
10 10
11void FAST_FUNC parse_datestr(const char *date_str, struct tm *tm_time) 11void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
12{ 12{
13 char end = '\0'; 13 char end = '\0';
14 const char *last_colon = strrchr(date_str, ':'); 14 const char *last_colon = strrchr(date_str, ':');
15 15
16 if (last_colon != NULL) { 16 if (last_colon != NULL) {
17 /* Parse input and assign appropriately to tm_time */ 17 /* Parse input and assign appropriately to ptm */
18 18
19 /* HH:MM */ 19 /* HH:MM */
20 if (sscanf(date_str, "%u:%u%c", 20 if (sscanf(date_str, "%u:%u%c",
21 &tm_time->tm_hour, 21 &ptm->tm_hour,
22 &tm_time->tm_min, 22 &ptm->tm_min,
23 &end) >= 2) { 23 &end) >= 2) {
24 /* no adjustments needed */ 24 /* no adjustments needed */
25 } else 25 } else
26 /* mm.dd-HH:MM */ 26 /* mm.dd-HH:MM */
27 if (sscanf(date_str, "%u.%u-%u:%u%c", 27 if (sscanf(date_str, "%u.%u-%u:%u%c",
28 &tm_time->tm_mon, &tm_time->tm_mday, 28 &ptm->tm_mon, &ptm->tm_mday,
29 &tm_time->tm_hour, &tm_time->tm_min, 29 &ptm->tm_hour, &ptm->tm_min,
30 &end) >= 4) { 30 &end) >= 4) {
31 /* Adjust month from 1-12 to 0-11 */ 31 /* Adjust month from 1-12 to 0-11 */
32 tm_time->tm_mon -= 1; 32 ptm->tm_mon -= 1;
33 } else 33 } else
34 /* yyyy.mm.dd-HH:MM */ 34 /* yyyy.mm.dd-HH:MM */
35 if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &tm_time->tm_year, 35 if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &ptm->tm_year,
36 &tm_time->tm_mon, &tm_time->tm_mday, 36 &ptm->tm_mon, &ptm->tm_mday,
37 &tm_time->tm_hour, &tm_time->tm_min, 37 &ptm->tm_hour, &ptm->tm_min,
38 &end) >= 5) { 38 &end) >= 5) {
39 tm_time->tm_year -= 1900; /* Adjust years */ 39 ptm->tm_year -= 1900; /* Adjust years */
40 tm_time->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ 40 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
41 } else 41 } else
42 /* yyyy-mm-dd HH:MM */ 42 /* yyyy-mm-dd HH:MM */
43 if (sscanf(date_str, "%u-%u-%u %u:%u%c", &tm_time->tm_year, 43 if (sscanf(date_str, "%u-%u-%u %u:%u%c", &ptm->tm_year,
44 &tm_time->tm_mon, &tm_time->tm_mday, 44 &ptm->tm_mon, &ptm->tm_mday,
45 &tm_time->tm_hour, &tm_time->tm_min, 45 &ptm->tm_hour, &ptm->tm_min,
46 &end) >= 5) { 46 &end) >= 5) {
47 tm_time->tm_year -= 1900; /* Adjust years */ 47 ptm->tm_year -= 1900; /* Adjust years */
48 tm_time->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ 48 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
49//TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes) 49//TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes)
50 } else { 50 } else {
51 bb_error_msg_and_die(bb_msg_invalid_date, date_str); 51 bb_error_msg_and_die(bb_msg_invalid_date, date_str);
52 } 52 }
53 if (end == ':') { 53 if (end == ':') {
54 /* xxx:SS */ 54 /* xxx:SS */
55 if (sscanf(last_colon + 1, "%u%c", &tm_time->tm_sec, &end) == 1) 55 if (sscanf(last_colon + 1, "%u%c", &ptm->tm_sec, &end) == 1)
56 end = '\0'; 56 end = '\0';
57 /* else end != NUL and we error out */ 57 /* else end != NUL and we error out */
58 } 58 }
@@ -75,60 +75,60 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *tm_time)
75 75
76 /* MM[.SS] */ 76 /* MM[.SS] */
77 if (len == 2 && sscanf(date_str, "%2u%2u%2u%2u""%2u%c" + 12, 77 if (len == 2 && sscanf(date_str, "%2u%2u%2u%2u""%2u%c" + 12,
78 &tm_time->tm_min, 78 &ptm->tm_min,
79 &end) >= 1) { 79 &end) >= 1) {
80 } else 80 } else
81 /* HHMM[.SS] */ 81 /* HHMM[.SS] */
82 if (len == 4 && sscanf(date_str, "%2u%2u%2u""%2u%2u%c" + 9, 82 if (len == 4 && sscanf(date_str, "%2u%2u%2u""%2u%2u%c" + 9,
83 &tm_time->tm_hour, 83 &ptm->tm_hour,
84 &tm_time->tm_min, 84 &ptm->tm_min,
85 &end) >= 2) { 85 &end) >= 2) {
86 } else 86 } else
87 /* ddHHMM[.SS] */ 87 /* ddHHMM[.SS] */
88 if (len == 6 && sscanf(date_str, "%2u%2u""%2u%2u%2u%c" + 6, 88 if (len == 6 && sscanf(date_str, "%2u%2u""%2u%2u%2u%c" + 6,
89 &tm_time->tm_mday, 89 &ptm->tm_mday,
90 &tm_time->tm_hour, 90 &ptm->tm_hour,
91 &tm_time->tm_min, 91 &ptm->tm_min,
92 &end) >= 3) { 92 &end) >= 3) {
93 } else 93 } else
94 /* mmddHHMM[.SS] */ 94 /* mmddHHMM[.SS] */
95 if (len == 8 && sscanf(date_str, "%2u""%2u%2u%2u%2u%c" + 3, 95 if (len == 8 && sscanf(date_str, "%2u""%2u%2u%2u%2u%c" + 3,
96 &tm_time->tm_mon, 96 &ptm->tm_mon,
97 &tm_time->tm_mday, 97 &ptm->tm_mday,
98 &tm_time->tm_hour, 98 &ptm->tm_hour,
99 &tm_time->tm_min, 99 &ptm->tm_min,
100 &end) >= 4) { 100 &end) >= 4) {
101 /* Adjust month from 1-12 to 0-11 */ 101 /* Adjust month from 1-12 to 0-11 */
102 tm_time->tm_mon -= 1; 102 ptm->tm_mon -= 1;
103 } else 103 } else
104 /* yymmddHHMM[.SS] */ 104 /* yymmddHHMM[.SS] */
105 if (len == 10 && sscanf(date_str, "%2u%2u%2u%2u%2u%c", 105 if (len == 10 && sscanf(date_str, "%2u%2u%2u%2u%2u%c",
106 &tm_time->tm_year, 106 &ptm->tm_year,
107 &tm_time->tm_mon, 107 &ptm->tm_mon,
108 &tm_time->tm_mday, 108 &ptm->tm_mday,
109 &tm_time->tm_hour, 109 &ptm->tm_hour,
110 &tm_time->tm_min, 110 &ptm->tm_min,
111 &end) >= 5) { 111 &end) >= 5) {
112 /* Adjust month from 1-12 to 0-11 */ 112 /* Adjust month from 1-12 to 0-11 */
113 tm_time->tm_mon -= 1; 113 ptm->tm_mon -= 1;
114 } else 114 } else
115 /* ccyymmddHHMM[.SS] */ 115 /* ccyymmddHHMM[.SS] */
116 if (len == 12 && sscanf(date_str, "%4u%2u%2u%2u%2u%c", 116 if (len == 12 && sscanf(date_str, "%4u%2u%2u%2u%2u%c",
117 &tm_time->tm_year, 117 &ptm->tm_year,
118 &tm_time->tm_mon, 118 &ptm->tm_mon,
119 &tm_time->tm_mday, 119 &ptm->tm_mday,
120 &tm_time->tm_hour, 120 &ptm->tm_hour,
121 &tm_time->tm_min, 121 &ptm->tm_min,
122 &end) >= 5) { 122 &end) >= 5) {
123 tm_time->tm_year -= 1900; /* Adjust years */ 123 ptm->tm_year -= 1900; /* Adjust years */
124 tm_time->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ 124 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
125 } else { 125 } else {
126 bb_error_msg_and_die(bb_msg_invalid_date, date_str); 126 bb_error_msg_and_die(bb_msg_invalid_date, date_str);
127 } 127 }
128 if (end == '.') { 128 if (end == '.') {
129 /* xxx.SS */ 129 /* xxx.SS */
130 if (sscanf(strchr(date_str, '.') + 1, "%u%c", 130 if (sscanf(strchr(date_str, '.') + 1, "%u%c",
131 &tm_time->tm_sec, &end) == 1) 131 &ptm->tm_sec, &end) == 1)
132 end = '\0'; 132 end = '\0';
133 /* else end != NUL and we error out */ 133 /* else end != NUL and we error out */
134 } 134 }
@@ -138,9 +138,9 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *tm_time)
138 } 138 }
139} 139}
140 140
141time_t FAST_FUNC validate_tm_time(const char *date_str, struct tm *tm_time) 141time_t FAST_FUNC validate_tm_time(const char *date_str, struct tm *ptm)
142{ 142{
143 time_t t = mktime(tm_time); 143 time_t t = mktime(ptm);
144 if (t == (time_t) -1L) { 144 if (t == (time_t) -1L) {
145 bb_error_msg_and_die(bb_msg_invalid_date, date_str); 145 bb_error_msg_and_die(bb_msg_invalid_date, date_str);
146 } 146 }
diff --git a/miscutils/crond.c b/miscutils/crond.c
index ad217f007..7135e4475 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -654,14 +654,14 @@ static int TestJobs(time_t t1, time_t t2)
654 /* Find jobs > t1 and <= t2 */ 654 /* Find jobs > t1 and <= t2 */
655 655
656 for (t = t1 - t1 % 60; t <= t2; t += 60) { 656 for (t = t1 - t1 % 60; t <= t2; t += 60) {
657 struct tm *tp; 657 struct tm *ptm;
658 CronFile *file; 658 CronFile *file;
659 CronLine *line; 659 CronLine *line;
660 660
661 if (t <= t1) 661 if (t <= t1)
662 continue; 662 continue;
663 663
664 tp = localtime(&t); 664 ptm = localtime(&t);
665 for (file = FileBase; file; file = file->cf_Next) { 665 for (file = FileBase; file; file = file->cf_Next) {
666 if (DebugOpt) 666 if (DebugOpt)
667 crondlog(LVL5 "file %s:", file->cf_User); 667 crondlog(LVL5 "file %s:", file->cf_User);
@@ -670,9 +670,9 @@ static int TestJobs(time_t t1, time_t t2)
670 for (line = file->cf_LineBase; line; line = line->cl_Next) { 670 for (line = file->cf_LineBase; line; line = line->cl_Next) {
671 if (DebugOpt) 671 if (DebugOpt)
672 crondlog(LVL5 " line %s", line->cl_Shell); 672 crondlog(LVL5 " line %s", line->cl_Shell);
673 if (line->cl_Mins[tp->tm_min] && line->cl_Hrs[tp->tm_hour] 673 if (line->cl_Mins[ptm->tm_min] && line->cl_Hrs[ptm->tm_hour]
674 && (line->cl_Days[tp->tm_mday] || line->cl_Dow[tp->tm_wday]) 674 && (line->cl_Days[ptm->tm_mday] || line->cl_Dow[ptm->tm_wday])
675 && line->cl_Mons[tp->tm_mon] 675 && line->cl_Mons[ptm->tm_mon]
676 ) { 676 ) {
677 if (DebugOpt) { 677 if (DebugOpt) {
678 crondlog(LVL5 " job: %d %s", 678 crondlog(LVL5 " job: %d %s",
diff --git a/networking/httpd_indexcgi.c b/networking/httpd_indexcgi.c
index 6663a22ad..9fa7c7481 100644
--- a/networking/httpd_indexcgi.c
+++ b/networking/httpd_indexcgi.c
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
291 size_total = 0; 291 size_total = 0;
292 cdir = dir_list; 292 cdir = dir_list;
293 while (dir_list_count--) { 293 while (dir_list_count--) {
294 struct tm *tm; 294 struct tm *ptm;
295 295
296 if (S_ISDIR(cdir->dl_mode)) { 296 if (S_ISDIR(cdir->dl_mode)) {
297 count_dirs++; 297 count_dirs++;
@@ -316,12 +316,12 @@ int main(int argc, char *argv[])
316 fmt_ull(cdir->dl_size); 316 fmt_ull(cdir->dl_size);
317 fmt_str("<td class=dt>"); 317 fmt_str("<td class=dt>");
318 tm = gmtime(&cdir->dl_mtime); 318 tm = gmtime(&cdir->dl_mtime);
319 fmt_04u(1900 + tm->tm_year); *dst++ = '-'; 319 fmt_04u(1900 + ptm->tm_year); *dst++ = '-';
320 fmt_02u(tm->tm_mon + 1); *dst++ = '-'; 320 fmt_02u(ptm->tm_mon + 1); *dst++ = '-';
321 fmt_02u(tm->tm_mday); *dst++ = ' '; 321 fmt_02u(ptm->tm_mday); *dst++ = ' ';
322 fmt_02u(tm->tm_hour); *dst++ = ':'; 322 fmt_02u(ptm->tm_hour); *dst++ = ':';
323 fmt_02u(tm->tm_min); *dst++ = ':'; 323 fmt_02u(ptm->tm_min); *dst++ = ':';
324 fmt_02u(tm->tm_sec); 324 fmt_02u(ptm->tm_sec);
325 *dst++ = '\n'; 325 *dst++ = '\n';
326 326
327 odd = 1 - odd; 327 odd = 1 - odd;
diff --git a/runit/svlogd.c b/runit/svlogd.c
index fe40cd890..f556c7db5 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -266,18 +266,18 @@ static char* wstrdup(const char *str)
266/* NUL terminated */ 266/* NUL terminated */
267static void fmt_time_human_30nul(char *s) 267static void fmt_time_human_30nul(char *s)
268{ 268{
269 struct tm *t; 269 struct tm *ptm;
270 struct timeval tv; 270 struct timeval tv;
271 271
272 gettimeofday(&tv, NULL); 272 gettimeofday(&tv, NULL);
273 t = gmtime(&(tv.tv_sec)); 273 ptm = gmtime(&tv.tv_sec);
274 sprintf(s, "%04u-%02u-%02u_%02u:%02u:%02u.%06u000", 274 sprintf(s, "%04u-%02u-%02u_%02u:%02u:%02u.%06u000",
275 (unsigned)(1900 + t->tm_year), 275 (unsigned)(1900 + ptm->tm_year),
276 (unsigned)(t->tm_mon + 1), 276 (unsigned)(ptm->tm_mon + 1),
277 (unsigned)(t->tm_mday), 277 (unsigned)(ptm->tm_mday),
278 (unsigned)(t->tm_hour), 278 (unsigned)(ptm->tm_hour),
279 (unsigned)(t->tm_min), 279 (unsigned)(ptm->tm_min),
280 (unsigned)(t->tm_sec), 280 (unsigned)(ptm->tm_sec),
281 (unsigned)(tv.tv_usec) 281 (unsigned)(tv.tv_usec)
282 ); 282 );
283 /* 4+1 + 2+1 + 2+1 + 2+1 + 2+1 + 2+1 + 9 = */ 283 /* 4+1 + 2+1 + 2+1 + 2+1 + 2+1 + 2+1 + 9 = */
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.
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
index e794b3145..54c068d0b 100644
--- a/util-linux/mkfs_vfat.c
+++ b/util-linux/mkfs_vfat.c
@@ -538,16 +538,16 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv)
538 // create dir entry for volume_label 538 // create dir entry for volume_label
539 struct msdos_dir_entry *de; 539 struct msdos_dir_entry *de;
540#if 0 540#if 0
541 struct tm tm; 541 struct tm tm_time;
542 uint16_t t, d; 542 uint16_t t, d;
543#endif 543#endif
544 de = (void*)buf; 544 de = (void*)buf;
545 strncpy(de->name, volume_label, sizeof(de->name)); 545 strncpy(de->name, volume_label, sizeof(de->name));
546 STORE_LE(de->attr, ATTR_VOLUME); 546 STORE_LE(de->attr, ATTR_VOLUME);
547#if 0 547#if 0
548 localtime_r(&create_time, &tm); 548 localtime_r(&create_time, &tm_time);
549 t = (tm.tm_sec >> 1) + (tm.tm_min << 5) + (tm.tm_hour << 11); 549 t = (tm_time.tm_sec >> 1) + (tm_time.tm_min << 5) + (tm_time.tm_hour << 11);
550 d = tm.tm_mday + ((tm.tm_mon+1) << 5) + ((tm.tm_year-80) << 9); 550 d = tm_time.tm_mday + ((tm_time.tm_mon+1) << 5) + ((tm_time.tm_year-80) << 9);
551 STORE_LE(de->time, t); 551 STORE_LE(de->time, t);
552 STORE_LE(de->date, d); 552 STORE_LE(de->date, d);
553 //STORE_LE(de->ctime_cs, 0); 553 //STORE_LE(de->ctime_cs, 0);
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c
index 64c3e7ed7..66b08e343 100644
--- a/util-linux/rtcwake.c
+++ b/util-linux/rtcwake.c
@@ -50,7 +50,7 @@ static NOINLINE bool may_wakeup(const char *rtcname)
50 50
51static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time) 51static NOINLINE void setup_alarm(int fd, time_t *wakeup, time_t rtc_time)
52{ 52{
53 struct tm *tm; 53 struct tm *ptm;
54 struct linux_rtc_wkalrm wake; 54 struct linux_rtc_wkalrm wake;
55 55
56 /* The wakeup time is in POSIX time (more or less UTC). 56 /* 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)
63 * Else mode is local so the time given to the RTC 63 * Else mode is local so the time given to the RTC
64 * will instead use the local time zone. 64 * will instead use the local time zone.
65 */ 65 */
66 tm = localtime(wakeup); 66 ptm = localtime(wakeup);
67 67
68 wake.time.tm_sec = tm->tm_sec; 68 wake.time.tm_sec = ptm->tm_sec;
69 wake.time.tm_min = tm->tm_min; 69 wake.time.tm_min = ptm->tm_min;
70 wake.time.tm_hour = tm->tm_hour; 70 wake.time.tm_hour = ptm->tm_hour;
71 wake.time.tm_mday = tm->tm_mday; 71 wake.time.tm_mday = ptm->tm_mday;
72 wake.time.tm_mon = tm->tm_mon; 72 wake.time.tm_mon = ptm->tm_mon;
73 wake.time.tm_year = tm->tm_year; 73 wake.time.tm_year = ptm->tm_year;
74 /* wday, yday, and isdst fields are unused by Linux */ 74 /* wday, yday, and isdst fields are unused by Linux */
75 wake.time.tm_wday = -1; 75 wake.time.tm_wday = -1;
76 wake.time.tm_yday = -1; 76 wake.time.tm_yday = -1;
@@ -161,9 +161,9 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
161 /* relative or absolute alarm time, normalized to time_t */ 161 /* relative or absolute alarm time, normalized to time_t */
162 sys_time = time(NULL); 162 sys_time = time(NULL);
163 { 163 {
164 struct tm tm; 164 struct tm tm_time;
165 rtc_read_tm(&tm, fd); 165 rtc_read_tm(&tm_time, fd);
166 rtc_time = rtc_tm2time(&tm, utc); 166 rtc_time = rtc_tm2time(&tm_time, utc);
167 } 167 }
168 168
169 169