From patchwork Tue Aug 20 13:21:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 34183 Received: (qmail 48066 invoked by alias); 20 Aug 2019 13:21:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 48058 invoked by uid 89); 20 Aug 2019 13:21:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=day, HContent-Transfer-Encoding:8bit X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: Joseph Myers , Florian Weimer , Lukasz Majewski , Alistair Francis , Stepan Golosunov , Arnd Bergmann Subject: [PATCH 03/12] =?UTF-8?q?Don=E2=80=99t=20use=20the=20argument=20to?= =?UTF-8?q?=20time.?= Date: Tue, 20 Aug 2019 09:21:43 -0400 Message-Id: <20190820132152.24100-4-zackw@panix.com> In-Reply-To: <20190820132152.24100-1-zackw@panix.com> References: <20190820132152.24100-1-zackw@panix.com> MIME-Version: 1.0 Unlike gettimeofday, I don’t think it makes sense to remove all the internal uses of time. Its callers don’t care about sub-second resolution and would be unnecessarily complicated if they had to declare a struct timespec instead of just a time_t. However, a handful of places were using the vestigial ‘result’ argument instead of the return value, which is ever so slightly less efficient and also looks weird. Correct this. * misc/syslog.c (__vsyslog_internal) * time/getdate.c (__getdate_r) * time/tst_wcsftime.c (main): Use return value of time, not its argument. * string/strfry.c (strfry) * sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL. Reviewed-by: Adhemerval Zanella --- misc/syslog.c | 2 +- string/strfry.c | 2 +- sysdeps/mach/sleep.c | 4 ++-- time/getdate.c | 2 +- time/tst_wcsftime.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/misc/syslog.c b/misc/syslog.c index 3a15da41ce..cf2deef533 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -205,7 +205,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap, { __fsetlocking (f, FSETLOCKING_BYCALLER); fprintf (f, "<%d>", pri); - (void) time (&now); + now = time (NULL); f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr, f->_IO_write_end - f->_IO_write_ptr, diff --git a/string/strfry.c b/string/strfry.c index af6087bee5..71686d45c2 100644 --- a/string/strfry.c +++ b/string/strfry.c @@ -30,7 +30,7 @@ strfry (char *string) { static char state[32]; rdata.state = NULL; - __initstate_r (time ((time_t *) NULL) ^ getpid (), + __initstate_r (time (NULL) ^ getpid (), state, sizeof (state), &rdata); init = 1; } diff --git a/sysdeps/mach/sleep.c b/sysdeps/mach/sleep.c index 11e1bb87f3..c63ef926b7 100644 --- a/sysdeps/mach/sleep.c +++ b/sysdeps/mach/sleep.c @@ -33,10 +33,10 @@ __sleep (unsigned int seconds) recv = __mach_reply_port (); - before = time ((time_t *) NULL); + before = time (NULL); (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT, 0, 0, recv, seconds * 1000, MACH_PORT_NULL); - after = time ((time_t *) NULL); + after = time (NULL); __mach_port_destroy (__mach_task_self (), recv); return seconds - (after - before); diff --git a/time/getdate.c b/time/getdate.c index aee96f7163..8a567c3fcd 100644 --- a/time/getdate.c +++ b/time/getdate.c @@ -219,7 +219,7 @@ __getdate_r (const char *string, struct tm *tp) return 7; /* Get current time. */ - time (&timer); + timer = time (NULL); __localtime_r (&timer, &tm); /* If only the weekday is given, today is assumed if the given day diff --git a/time/tst_wcsftime.c b/time/tst_wcsftime.c index 3f6f0d9f77..55c45f6a81 100644 --- a/time/tst_wcsftime.c +++ b/time/tst_wcsftime.c @@ -10,7 +10,7 @@ main (int argc, char *argv[]) int result = 0; size_t n; - time (&t); + t = time (NULL); tp = gmtime (&t); n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),