public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/y2038-preliminaries] Don’t use the argument to time.
@ 2019-08-20 12:07 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-20 12:07 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3348 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c101e8b1860b24eba152d92b5551b3d231113508
commit c101e8b1860b24eba152d92b5551b3d231113508
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Donât use the argument to time.
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)
* string/strfry.c (strfry)
* time/getdate.c (__getdate_r)
* time/tst_wcsftime.c (main):
Use return value of time, not its argument.
* sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL.
Diff:
---
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 3a15da4..cf2deef 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 af6087b..71686d4 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 11e1bb8..c63ef92 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 aee96f7..8a567c3 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 3f6f0d9..55c45f6 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]),
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Don't use the argument to time.
@ 2019-08-21 12:27 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-21 12:27 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1baae4aa6f3313da77d799f12f963910b05db637
commit 1baae4aa6f3313da77d799f12f963910b05db637
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Don't use the argument to time.
It doesn't make sense to remove all the internal uses of time.
It's still a standard ISO C function, and its callers don't need
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 slightly less
efficient and also looks strange. 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 in calls to time.
Diff:
---
ChangeLog | 11 +++++++++++
misc/syslog.c | 2 +-
string/strfry.c | 2 +-
sysdeps/mach/sleep.c | 4 ++--
time/getdate.c | 2 +-
time/tst_wcsftime.c | 2 +-
6 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ee96090..5e07cee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-08-21 Zack Weinberg <zackw@panix.com>
+
+ * 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 in calls to time.
+
2019-08-21 Joseph Myers <joseph@codesourcery.com>
* math/tgmath.h [__HAVE_FLOAT128X]: Give error.
diff --git a/misc/syslog.c b/misc/syslog.c
index 3a15da4..cf2deef 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 af6087b..71686d4 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 11e1bb8..c63ef92 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 aee96f7..8a567c3 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 3f6f0d9..55c45f6 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]),
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Don’t use the argument to time.
@ 2019-08-20 13:24 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-20 13:24 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3353 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2b46d373df083f3f4e9b5e763abc72ba6a42f264
commit 2b46d373df083f3f4e9b5e763abc72ba6a42f264
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Donât use the argument to time.
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.
Diff:
---
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 3a15da4..cf2deef 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 af6087b..71686d4 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 11e1bb8..c63ef92 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 aee96f7..8a567c3 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 3f6f0d9..55c45f6 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]),
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Don’t use the argument to time.
@ 2019-08-19 18:31 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-19 18:31 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3348 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e0c5b8187dc0cc334e6667c4a8ab0d4104eb72a8
commit e0c5b8187dc0cc334e6667c4a8ab0d4104eb72a8
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Donât use the argument to time.
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)
* string/strfry.c (strfry)
* time/getdate.c (__getdate_r)
* time/tst_wcsftime.c (main):
Use return value of time, not its argument.
* sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL.
Diff:
---
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 3a15da4..cf2deef 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 af6087b..71686d4 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 11e1bb8..c63ef92 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 aee96f7..8a567c3 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 3f6f0d9..55c45f6 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]),
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Don’t use the argument to time.
@ 2019-08-17 1:17 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-17 1:17 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3350 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a7450c43a8694b6e916d609b7b5668b65625b8a3
commit a7450c43a8694b6e916d609b7b5668b65625b8a3
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 21:10:11 2019 -0400
Donât use the argument to time.
Unlike gettimeofday, I donât think it makes sense to remove all the
internal uses of time. These 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)
* string/strfry.c (strfry)
* time/getdate.c (__getdate_r)
* time/tst_wcsftime.c (main):
Use return value of time, not its argument.
* sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL.
Diff:
---
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 3a15da4..cf2deef 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 af6087b..71686d4 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 11e1bb8..c63ef92 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 aee96f7..8a567c3 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 3f6f0d9..55c45f6 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]),
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-08-21 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 12:07 [glibc/zack/y2038-preliminaries] Don’t use the argument to time Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2019-08-21 12:27 [glibc/zack/y2038-preliminaries] Don't " Zack Weinberg
2019-08-20 13:24 [glibc/zack/y2038-preliminaries] Don’t " Zack Weinberg
2019-08-19 18:31 Zack Weinberg
2019-08-17 1:17 Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).