]> The Tcpdump Group git mirrors - tcpdump/blobdiff - util-print.c
Fix incompatible pointer types with time functions calls on Windows
[tcpdump] / util-print.c
index fcf72ffd872a729b3db3eff42ba57e7df754a606..f055725c92080f77907d4cb18f0c487d846eaa59 100644 (file)
@@ -249,16 +249,32 @@ ts_date_hmsfrac_print(netdissect_options *ndo, const struct timeval *tv,
        struct tm *tm;
        char timebuf[32];
        const char *timestr;
+#ifdef _WIN32
+       time_t sec;
+#endif
 
        if (tv->tv_sec < 0) {
                ND_PRINT("[timestamp overflow]");
                return;
        }
 
+#ifdef _WIN32
+       /* on Windows tv->tv_sec is a long not a 64-bit time_t. */
+       sec = tv->tv_sec;
+#endif
+
        if (time_flag == LOCAL_TIME)
+#ifdef _WIN32
+               tm = localtime(&sec);
+#else
                tm = localtime(&tv->tv_sec);
+#endif
        else
+#ifdef _WIN32
+               tm = gmtime(&sec);
+#else
                tm = gmtime(&tv->tv_sec);
+#endif
 
        if (date_flag == WITH_DATE) {
                timestr = nd_format_time(timebuf, sizeof(timebuf),