diff options
author | Tee KOBAYASHI <xtkoba@gmail.com> | 2022-06-26 17:40:29 +0900 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-06-29 12:11:17 +1000 |
commit | 8eca6864e080c9b8197fec81cd6f327be43bb14c (patch) | |
tree | bd76a59e18a3830f60444da01094e63ee6e53d63 /crypto/bio | |
parent | 8e949b35d396005d63f3a2c944c36a1c94e41019 (diff) |
Avoid using union wrt. SystemTimeToFileTime
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18660)
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/bss_dgram.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index 4b363829af..7201c6ae63 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -1900,20 +1900,19 @@ static void get_current_time(struct timeval *t) { # if defined(_WIN32) SYSTEMTIME st; - union { - unsigned __int64 ul; - FILETIME ft; - } now; + unsigned __int64 now_ul; + FILETIME now_ft; GetSystemTime(&st); - SystemTimeToFileTime(&st, &now.ft); + SystemTimeToFileTime(&st, &now_ft); + now_ul = ((unsigned __int64)now_ft.dwHighDateTime << 32) | now_ft.dwLowDateTime; # ifdef __MINGW32__ - now.ul -= 116444736000000000ULL; + now_ul -= 116444736000000000ULL; # else - now.ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */ + now_ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */ # endif - t->tv_sec = (long)(now.ul / 10000000); - t->tv_usec = ((int)(now.ul % 10000000)) / 10; + t->tv_sec = (long)(now_ul / 10000000); + t->tv_usec = ((int)(now_ul % 10000000)) / 10; # else gettimeofday(t, NULL); # endif |