From 00893e79fc62966067af1a106567db96bd170338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 3 Mar 2024 19:11:32 +0100 Subject: New upstream version 1.2 --- tests/gettimeofday.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tests/gettimeofday.c') diff --git a/tests/gettimeofday.c b/tests/gettimeofday.c index 36c7920a..8dd26f73 100644 --- a/tests/gettimeofday.c +++ b/tests/gettimeofday.c @@ -1,6 +1,6 @@ /* Provide gettimeofday for systems that don't have it or for which it's broken. - Copyright (C) 2001-2003, 2005-2007, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -113,8 +113,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) ULONGLONG since_1970 = since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000; ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10; - tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000; - tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000; + *tv = (struct timeval) { + .tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000, + .tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000 + }; return 0; @@ -127,10 +129,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) struct timeval otv; int result = gettimeofday (&otv, (struct timezone *) tz); if (result == 0) - { - tv->tv_sec = otv.tv_sec; - tv->tv_usec = otv.tv_usec; - } + *tv = otv; # else int result = gettimeofday (tv, (struct timezone *) tz); # endif @@ -143,8 +142,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) # error "Only 1-second nominal clock resolution found. Is that intended?" \ "If so, compile with the -DOK_TO_USE_1S_CLOCK option." # endif - tv->tv_sec = time (NULL); - tv->tv_usec = 0; + *tv = (struct timeval) { .tv_sec = time (NULL), .tv_usec = 0 }; return 0; -- cgit v1.2.3