From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40693 invoked by alias); 20 Aug 2019 18:53:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 40685 invoked by uid 89); 20 Aug 2019 18:53:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=divide X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH 02/12] Change most internal uses of __gettimeofday to __clock_gettime. To: Zack Weinberg , libc-alpha@sourceware.org Cc: Joseph Myers , Florian Weimer , Lukasz Majewski , Alistair Francis , Stepan Golosunov , Arnd Bergmann References: <20190820132152.24100-1-zackw@panix.com> <20190820132152.24100-3-zackw@panix.com> From: Paul Eggert Message-ID: <0632b772-8e4d-bc02-8af9-82adf0c0ee11@cs.ucla.edu> Date: Tue, 20 Aug 2019 18:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190820132152.24100-3-zackw@panix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2019-08/txt/msg00533.txt.bz2 Zack Weinberg wrote: > + long int end = (now.tv_sec * 1000 + usectmo + > + (now.tv_nsec + 500000) / 1000000); The usual GNU style is to put that trailing "+" at the start of the next line instead, here and elsewhere. > --- a/support/support_test_main.c > +++ b/support/support_test_main.c > @@ -88,16 +88,16 @@ static pid_t test_pid; > static void (*cleanup_function) (void); > > static void > -print_timestamp (const char *what, struct timeval tv) > +print_timestamp (const char *what, struct timespec tv) > { > struct tm tm; > if (gmtime_r (&tv.tv_sec, &tm) == NULL) > printf ("%s: %lld.%06d\n", > - what, (long long int) tv.tv_sec, (int) tv.tv_usec); > + what, (long long int) tv.tv_sec, (int) tv.tv_nsec / 1000); > else > printf ("%s: %04d-%02d-%02dT%02d:%02d:%02d.%06d\n", > what, 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, > - tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tv.tv_usec); > + tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tv.tv_nsec / 1000); > } Since the goal of this test code is to print the timestamp, the code should simply use %09d in the format and not divide by 1000.