Skip to content
Snippets Groups Projects
Commit c30c6917 authored by Rob Swindell's avatar Rob Swindell :speech_balloon: Committed by Deucе
Browse files

Use difftime() in checktime() as Deuce suggested

Fix some newly introduced MSVC warnings:
  conversion from 'time_t' to 'uint32_t', possible loss of data

Should these local vars be time32_t instead of uint32_t?

I'm not clear why the 2 step conversions now (?):
	time_t -> uint32_t
	uint32_t -> time32_t
parent a395a564
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ time_t checktime(void)
tmp = gmtime_r(&t,&gmt);
if(tmp == NULL)
return -1;
return mktime(&tm) - mktime(tmp);
return (time_t)difftime(mktime(&tm), mktime(tmp));
}
/* Compensates for struct tm "weirdness" */
......@@ -71,7 +71,7 @@ time32_t time32(time32_t* tp)
t=time(NULL);
/* coverity[store_truncates_time_t] */
t32 = t;
t32 = (uint32_t)t;
if(tp!=NULL)
*tp=(time32_t)t32;
......@@ -83,7 +83,7 @@ time32_t mktime32(struct tm* tm)
{
time_t t = mktime(tm);
/* coverity[store_truncates_time_t] */
uint32_t t32 = t;
uint32_t t32 = (uint32_t)t;
return (time32_t)t32; /* don't use sane_mktime since tm->tm_mon is assumed to be already zero-based */
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment