*: make it easier to distinquish "struct tm", pointer to one, etc
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 9 Jan 2010 18:10:49 +0000 (19:10 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 9 Jan 2010 18:10:49 +0000 (19:10 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
13 files changed:
archival/libunarchive/header_verbose_list.c
archival/rpm.c
coreutils/cal.c
include/libbb.h
include/rtc_.h
libbb/rtc.c
libbb/time.c
miscutils/crond.c
networking/httpd_indexcgi.c
runit/svlogd.c
util-linux/hwclock.c
util-linux/mkfs_vfat.c
util-linux/rtcwake.c

index da21a15..f6f04cf 100644 (file)
@@ -8,7 +8,8 @@
 
 void FAST_FUNC header_verbose_list(const file_header_t *file_header)
 {
-       struct tm *mtime = localtime(&(file_header->mtime));
+       struct tm tm_time;
+       struct tm *ptm = &tm_time; //localtime(&file_header->mtime);
 
 #if ENABLE_FEATURE_TAR_UNAME_GNAME
        char uid[sizeof(int)*3 + 2];
@@ -16,6 +17,8 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
        char *user;
        char *group;
 
+       localtime_r(&file_header->mtime, ptm);
+
        user = file_header->tar__uname;
        if (user == NULL) {
                sprintf(uid, "%u", (unsigned)file_header->uid);
@@ -31,26 +34,31 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
                user,
                group,
                file_header->size,
-               1900 + mtime->tm_year,
-               1 + mtime->tm_mon,
-               mtime->tm_mday,
-               mtime->tm_hour,
-               mtime->tm_min,
-               mtime->tm_sec,
+               1900 + ptm->tm_year,
+               1 + ptm->tm_mon,
+               ptm->tm_mday,
+               ptm->tm_hour,
+               ptm->tm_min,
+               ptm->tm_sec,
                file_header->name);
+
 #else /* !FEATURE_TAR_UNAME_GNAME */
+
+       localtime_r(&file_header->mtime, ptm);
+
        printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
                bb_mode_string(file_header->mode),
                (unsigned)file_header->uid,
                (unsigned)file_header->gid,
                file_header->size,
-               1900 + mtime->tm_year,
-               1 + mtime->tm_mon,
-               mtime->tm_mday,
-               mtime->tm_hour,
-               mtime->tm_min,
-               mtime->tm_sec,
+               1900 + ptm->tm_year,
+               1 + ptm->tm_mon,
+               ptm->tm_mday,
+               ptm->tm_hour,
+               ptm->tm_min,
+               ptm->tm_sec,
                file_header->name);
+
 #endif /* FEATURE_TAR_UNAME_GNAME */
 
        if (file_header->link_target) {
index cdaf50f..6c1e341 100644 (file)
@@ -145,13 +145,13 @@ int rpm_main(int argc, char **argv)
                        if (func & rpm_query_info) {
                                /* Do the nice printout */
                                time_t bdate_time;
-                               struct tm *bdate;
+                               struct tm *bdate_ptm;
                                char bdatestring[50];
                                printf("Name        : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_PREFIXS, 0) ? rpm_getstr(TAG_PREFIXS, 0) : "(not relocateable)");
                                printf("Version     : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_VENDOR, 0) ? rpm_getstr(TAG_VENDOR, 0) : "(none)");
                                bdate_time = rpm_getint(TAG_BUILDTIME, 0);
-                               bdate = localtime((time_t *) &bdate_time);
-                               strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate);
+                               bdate_ptm = localtime(&bdate_time);
+                               strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm);
                                printf("Release     : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring);
                                printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0));
                                printf("Group       : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), rpm_getstr(TAG_SOURCERPM, 0));
index 8236442..e6f9af9 100644 (file)
@@ -79,7 +79,6 @@ static char *build_row(char *p, unsigned *dp);
 int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int cal_main(int argc UNUSED_PARAM, char **argv)
 {
-       struct tm *local_time;
        struct tm zero_tm;
        time_t now;
        unsigned month, year, flags, i;
@@ -94,11 +93,13 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
        argv += optind;
 
        if (!argv[0]) {
+               struct tm *ptm;
+
                time(&now);
-               local_time = localtime(&now);
-               year = local_time->tm_year + 1900;
+               ptm = localtime(&now);
+               year = ptm->tm_year + 1900;
                if (!(flags & 2)) { /* no -y */
-                       month = local_time->tm_mon + 1;
+                       month = ptm->tm_mon + 1;
                }
        } else {
                if (argv[1]) {
index cda59dc..e07bb52 100644 (file)
@@ -444,8 +444,8 @@ struct BUG_too_small {
 };
 
 
-void parse_datestr(const char *date_str, struct tm *tm_time) FAST_FUNC;
-time_t validate_tm_time(const char *date_str, struct tm *tm_time) FAST_FUNC;
+void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC;
+time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC;
 
 
 int xsocket(int domain, int type, int protocol) FAST_FUNC;
index 2b4ae77..b5fe8ec 100644 (file)
@@ -13,8 +13,8 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
 
 int rtc_adjtime_is_utc(void) FAST_FUNC;
 int rtc_xopen(const char **default_rtc, int flags) FAST_FUNC;
-void rtc_read_tm(struct tm *tm, int fd) FAST_FUNC;
-time_t rtc_tm2time(struct tm *tm, int utc) FAST_FUNC;
+void rtc_read_tm(struct tm *ptm, int fd) FAST_FUNC;
+time_t rtc_tm2time(struct tm *ptm, int utc) FAST_FUNC;
 
 
 /*
index 9807e1c..fcd6c64 100644 (file)
@@ -59,14 +59,14 @@ int FAST_FUNC rtc_xopen(const char **default_rtc, int flags)
        return xopen(*default_rtc, flags);
 }
 
-void FAST_FUNC rtc_read_tm(struct tm *tm, int fd)
+void FAST_FUNC rtc_read_tm(struct tm *ptm, int fd)
 {
-       memset(tm, 0, sizeof(*tm));
-       xioctl(fd, RTC_RD_TIME, tm);
-       tm->tm_isdst = -1; /* "not known" */
+       memset(ptm, 0, sizeof(*ptm));
+       xioctl(fd, RTC_RD_TIME, ptm);
+       ptm->tm_isdst = -1; /* "not known" */
 }
 
-time_t FAST_FUNC rtc_tm2time(struct tm *tm, int utc)
+time_t FAST_FUNC rtc_tm2time(struct tm *ptm, int utc)
 {
        char *oldtz = oldtz; /* for compiler */
        time_t t;
@@ -77,7 +77,7 @@ time_t FAST_FUNC rtc_tm2time(struct tm *tm, int utc)
                tzset();
        }
 
-       t = mktime(tm);
+       t = mktime(ptm);
 
        if (utc) {
                unsetenv("TZ");
index 85c72d1..82a0fa1 100644 (file)
@@ -8,51 +8,51 @@
  */
 #include "libbb.h"
 
-void FAST_FUNC parse_datestr(const char *date_str, struct tm *tm_time)
+void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
 {
        char end = '\0';
        const char *last_colon = strrchr(date_str, ':');
 
        if (last_colon != NULL) {
-               /* Parse input and assign appropriately to tm_time */
+               /* Parse input and assign appropriately to ptm */
 
                /* HH:MM */
                if (sscanf(date_str, "%u:%u%c",
-                                       &tm_time->tm_hour,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_hour,
+                                       &ptm->tm_min,
                                        &end) >= 2) {
                        /* no adjustments needed */
                } else
                /* mm.dd-HH:MM */
                if (sscanf(date_str, "%u.%u-%u:%u%c",
-                                       &tm_time->tm_mon, &tm_time->tm_mday,
-                                       &tm_time->tm_hour, &tm_time->tm_min,
+                                       &ptm->tm_mon, &ptm->tm_mday,
+                                       &ptm->tm_hour, &ptm->tm_min,
                                        &end) >= 4) {
                        /* Adjust month from 1-12 to 0-11 */
-                       tm_time->tm_mon -= 1;
+                       ptm->tm_mon -= 1;
                } else
                /* yyyy.mm.dd-HH:MM */
-               if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &tm_time->tm_year,
-                                       &tm_time->tm_mon, &tm_time->tm_mday,
-                                       &tm_time->tm_hour, &tm_time->tm_min,
+               if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &ptm->tm_year,
+                                       &ptm->tm_mon, &ptm->tm_mday,
+                                       &ptm->tm_hour, &ptm->tm_min,
                                        &end) >= 5) {
-                       tm_time->tm_year -= 1900; /* Adjust years */
-                       tm_time->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
+                       ptm->tm_year -= 1900; /* Adjust years */
+                       ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
                } else
                /* yyyy-mm-dd HH:MM */
-               if (sscanf(date_str, "%u-%u-%u %u:%u%c", &tm_time->tm_year,
-                                       &tm_time->tm_mon, &tm_time->tm_mday,
-                                       &tm_time->tm_hour, &tm_time->tm_min,
+               if (sscanf(date_str, "%u-%u-%u %u:%u%c", &ptm->tm_year,
+                                       &ptm->tm_mon, &ptm->tm_mday,
+                                       &ptm->tm_hour, &ptm->tm_min,
                                        &end) >= 5) {
-                       tm_time->tm_year -= 1900; /* Adjust years */
-                       tm_time->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
+                       ptm->tm_year -= 1900; /* Adjust years */
+                       ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
 //TODO: coreutils 6.9 also accepts "yyyy-mm-dd HH" (no minutes)
                } else {
                        bb_error_msg_and_die(bb_msg_invalid_date, date_str);
                }
                if (end == ':') {
                        /* xxx:SS */
-                       if (sscanf(last_colon + 1, "%u%c", &tm_time->tm_sec, &end) == 1)
+                       if (sscanf(last_colon + 1, "%u%c", &ptm->tm_sec, &end) == 1)
                                end = '\0';
                        /* else end != NUL and we error out */
                }
@@ -75,60 +75,60 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *tm_time)
 
                /* MM[.SS] */
                if (len == 2 && sscanf(date_str, "%2u%2u%2u%2u""%2u%c" + 12,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_min,
                                        &end) >= 1) {
                } else
                /* HHMM[.SS] */
                if (len == 4 && sscanf(date_str, "%2u%2u%2u""%2u%2u%c" + 9,
-                                       &tm_time->tm_hour,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_hour,
+                                       &ptm->tm_min,
                                        &end) >= 2) {
                } else
                /* ddHHMM[.SS] */
                if (len == 6 && sscanf(date_str, "%2u%2u""%2u%2u%2u%c" + 6,
-                                       &tm_time->tm_mday,
-                                       &tm_time->tm_hour,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_mday,
+                                       &ptm->tm_hour,
+                                       &ptm->tm_min,
                                        &end) >= 3) {
                } else
                /* mmddHHMM[.SS] */
                if (len == 8 && sscanf(date_str, "%2u""%2u%2u%2u%2u%c" + 3,
-                                       &tm_time->tm_mon,
-                                       &tm_time->tm_mday,
-                                       &tm_time->tm_hour,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_mon,
+                                       &ptm->tm_mday,
+                                       &ptm->tm_hour,
+                                       &ptm->tm_min,
                                        &end) >= 4) {
                        /* Adjust month from 1-12 to 0-11 */
-                       tm_time->tm_mon -= 1;
+                       ptm->tm_mon -= 1;
                } else
                /* yymmddHHMM[.SS] */
                if (len == 10 && sscanf(date_str, "%2u%2u%2u%2u%2u%c",
-                                       &tm_time->tm_year,
-                                       &tm_time->tm_mon,
-                                       &tm_time->tm_mday,
-                                       &tm_time->tm_hour,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_year,
+                                       &ptm->tm_mon,
+                                       &ptm->tm_mday,
+                                       &ptm->tm_hour,
+                                       &ptm->tm_min,
                                        &end) >= 5) {
                        /* Adjust month from 1-12 to 0-11 */
-                       tm_time->tm_mon -= 1;
+                       ptm->tm_mon -= 1;
                } else
                /* ccyymmddHHMM[.SS] */
                if (len == 12 && sscanf(date_str, "%4u%2u%2u%2u%2u%c",
-                                       &tm_time->tm_year,
-                                       &tm_time->tm_mon,
-                                       &tm_time->tm_mday,
-                                       &tm_time->tm_hour,
-                                       &tm_time->tm_min,
+                                       &ptm->tm_year,
+                                       &ptm->tm_mon,
+                                       &ptm->tm_mday,
+                                       &ptm->tm_hour,
+                                       &ptm->tm_min,
                                        &end) >= 5) {
-                       tm_time->tm_year -= 1900; /* Adjust years */
-                       tm_time->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
+                       ptm->tm_year -= 1900; /* Adjust years */
+                       ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
                } else {
                        bb_error_msg_and_die(bb_msg_invalid_date, date_str);
                }
                if (end == '.') {
                        /* xxx.SS */
                        if (sscanf(strchr(date_str, '.') + 1, "%u%c",
-                                       &tm_time->tm_sec, &end) == 1)
+                                       &ptm->tm_sec, &end) == 1)
                                end = '\0';
                        /* else end != NUL and we error out */
                }
@@ -138,9 +138,9 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *tm_time)
        }
 }
 
-time_t FAST_FUNC validate_tm_time(const char *date_str, struct tm *tm_time)
+time_t FAST_FUNC validate_tm_time(const char *date_str, struct tm *ptm)
 {
-       time_t t = mktime(tm_time);
+       time_t t = mktime(ptm);
        if (t == (time_t) -1L) {
                bb_error_msg_and_die(bb_msg_invalid_date, date_str);
        }
index ad217f0..7135e44 100644 (file)
@@ -654,14 +654,14 @@ static int TestJobs(time_t t1, time_t t2)
        /* Find jobs > t1 and <= t2 */
 
        for (t = t1 - t1 % 60; t <= t2; t += 60) {
-               struct tm *tp;
+               struct tm *ptm;
                CronFile *file;
                CronLine *line;
 
                if (t <= t1)
                        continue;
 
-               tp = localtime(&t);
+               ptm = localtime(&t);
                for (file = FileBase; file; file = file->cf_Next) {
                        if (DebugOpt)
                                crondlog(LVL5 "file %s:", file->cf_User);
@@ -670,9 +670,9 @@ static int TestJobs(time_t t1, time_t t2)
                        for (line = file->cf_LineBase; line; line = line->cl_Next) {
                                if (DebugOpt)
                                        crondlog(LVL5 " line %s", line->cl_Shell);
-                               if (line->cl_Mins[tp->tm_min] && line->cl_Hrs[tp->tm_hour]
-                                && (line->cl_Days[tp->tm_mday] || line->cl_Dow[tp->tm_wday])
-                                && line->cl_Mons[tp->tm_mon]
+                               if (line->cl_Mins[ptm->tm_min] && line->cl_Hrs[ptm->tm_hour]
+                                && (line->cl_Days[ptm->tm_mday] || line->cl_Dow[ptm->tm_wday])
+                                && line->cl_Mons[ptm->tm_mon]
                                ) {
                                        if (DebugOpt) {
                                                crondlog(LVL5 " job: %d %s",
index 6663a22..9fa7c74 100644 (file)
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
        size_total = 0;
        cdir = dir_list;
        while (dir_list_count--) {
-               struct tm *tm;
+               struct tm *ptm;
 
                if (S_ISDIR(cdir->dl_mode)) {
                        count_dirs++;
@@ -316,12 +316,12 @@ int main(int argc, char *argv[])
                        fmt_ull(cdir->dl_size);
                fmt_str("<td class=dt>");
                tm = gmtime(&cdir->dl_mtime);
-               fmt_04u(1900 + tm->tm_year); *dst++ = '-';
-               fmt_02u(tm->tm_mon + 1); *dst++ = '-';
-               fmt_02u(tm->tm_mday); *dst++ = ' ';
-               fmt_02u(tm->tm_hour); *dst++ = ':';
-               fmt_02u(tm->tm_min); *dst++ = ':';
-               fmt_02u(tm->tm_sec);
+               fmt_04u(1900 + ptm->tm_year); *dst++ = '-';
+               fmt_02u(ptm->tm_mon + 1); *dst++ = '-';
+               fmt_02u(ptm->tm_mday); *dst++ = ' ';
+               fmt_02u(ptm->tm_hour); *dst++ = ':';
+               fmt_02u(ptm->tm_min); *dst++ = ':';
+               fmt_02u(ptm->tm_sec);
                *dst++ = '\n';
 
                odd = 1 - odd;
index fe40cd8..f556c7d 100644 (file)
@@ -266,18 +266,18 @@ static char* wstrdup(const char *str)
 /* NUL terminated */
 static void fmt_time_human_30nul(char *s)
 {
-       struct tm *t;
+       struct tm *ptm;
        struct timeval tv;
 
        gettimeofday(&tv, NULL);
-       t = gmtime(&(tv.tv_sec));
+       ptm = gmtime(&tv.tv_sec);
        sprintf(s, "%04u-%02u-%02u_%02u:%02u:%02u.%06u000",
-               (unsigned)(1900 + t->tm_year),
-               (unsigned)(t->tm_mon + 1),
-               (unsigned)(t->tm_mday),
-               (unsigned)(t->tm_hour),
-               (unsigned)(t->tm_min),
-               (unsigned)(t->tm_sec),
+               (unsigned)(1900 + ptm->tm_year),
+               (unsigned)(ptm->tm_mon + 1),
+               (unsigned)(ptm->tm_mday),
+               (unsigned)(ptm->tm_hour),
+               (unsigned)(ptm->tm_min),
+               (unsigned)(ptm->tm_sec),
                (unsigned)(tv.tv_usec)
        );
        /* 4+1 + 2+1 + 2+1 + 2+1 + 2+1 + 2+1 + 9 = */
index ac89d45..b830057 100644 (file)
 #endif
 static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc)
 {
-       struct tm tm;
+       struct tm tm_time;
        int fd;
 
        fd = rtc_xopen(pp_rtcname, O_RDONLY);
 
-       rtc_read_tm(&tm, fd);
+       rtc_read_tm(&tm_time, fd);
 
 #if SHOW_HWCLOCK_DIFF
        {
-               int before = tm.tm_sec;
+               int before = tm_time.tm_sec;
                while (1) {
-                       rtc_read_tm(&tm, fd);
+                       rtc_read_tm(&tm_time, fd);
                        gettimeofday(sys_tv, NULL);
-                       if (before != tm.tm_sec)
+                       if (before != tm_time.tm_sec)
                                break;
                }
        }
@@ -59,7 +59,7 @@ static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc)
        if (ENABLE_FEATURE_CLEAN_UP)
                close(fd);
 
-       return rtc_tm2time(&tm, utc);
+       return rtc_tm2time(&tm_time, utc);
 }
 
 static void show_clock(const char **pp_rtcname, int utc)
@@ -110,7 +110,7 @@ static void to_sys_clock(const char **pp_rtcname, int utc)
 static void from_sys_clock(const char **pp_rtcname, int utc)
 {
 #define TWEAK_USEC 200
-       struct tm tm;
+       struct tm tm_time;
        struct timeval tv;
        unsigned adj = TWEAK_USEC;
        int rtc = rtc_xopen(pp_rtcname, O_WRONLY);
@@ -132,10 +132,10 @@ static void from_sys_clock(const char **pp_rtcname, int utc)
 
                /* Prepare tm */
                if (utc)
-                       gmtime_r(&t, &tm); /* may read /etc/xxx (it takes time) */
+                       gmtime_r(&t, &tm_time); /* may read /etc/xxx (it takes time) */
                else
-                       localtime_r(&t, &tm); /* same */
-               tm.tm_isdst = 0;
+                       localtime_r(&t, &tm_time); /* same */
+               tm_time.tm_isdst = 0;
 
                /* gmtime/localtime took some time, re-get cur time */
                gettimeofday(&tv, NULL);
@@ -166,7 +166,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc)
                usleep(rem_usec - adj);
        }
 
-       xioctl(rtc, RTC_SET_TIME, &tm);
+       xioctl(rtc, RTC_SET_TIME, &tm_time);
 
        /* Debug aid to find "good" TWEAK_USEC.
         * Look for a value which makes tv_usec close to 999999 or 0.
index e794b31..54c068d 100644 (file)
@@ -538,16 +538,16 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv)
                // create dir entry for volume_label
                struct msdos_dir_entry *de;
 #if 0
-               struct tm tm;
+               struct tm tm_time;
                uint16_t t, d;
 #endif
                de = (void*)buf;
                strncpy(de->name, volume_label, sizeof(de->name));
                STORE_LE(de->attr, ATTR_VOLUME);
 #if 0
-               localtime_r(&create_time, &tm);
-               t = (tm.tm_sec >> 1) + (tm.tm_min << 5) + (tm.tm_hour << 11);
-               d = tm.tm_mday + ((tm.tm_mon+1) << 5) + ((tm.tm_year-80) << 9);
+               localtime_r(&create_time, &tm_time);
+               t = (tm_time.tm_sec >> 1) + (tm_time.tm_min << 5) + (tm_time.tm_hour << 11);
+               d = tm_time.tm_mday + ((tm_time.tm_mon+1) << 5) + ((tm_time.tm_year-80) << 9);
                STORE_LE(de->time, t);
                STORE_LE(de->date, d);
                //STORE_LE(de->ctime_cs, 0);
index 64c3e7e..66b08e3 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;
@@ -161,9 +161,9 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
        /* relative or absolute alarm time, normalized to time_t */
        sys_time = time(NULL);
        {
-               struct tm tm;
-               rtc_read_tm(&tm, fd);
-               rtc_time = rtc_tm2time(&tm, utc);
+               struct tm tm_time;
+               rtc_read_tm(&tm_time, fd);
+               rtc_time = rtc_tm2time(&tm_time, utc);
        }