mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 08:40:07 +00:00
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.
This commit is contained in:
parent
f9fabc1b02
commit
1baae4aa6f
11
ChangeLog
11
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>
|
2019-08-21 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* math/tgmath.h [__HAVE_FLOAT128X]: Give error.
|
* math/tgmath.h [__HAVE_FLOAT128X]: Give error.
|
||||||
|
@ -205,7 +205,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
|
|||||||
{
|
{
|
||||||
__fsetlocking (f, FSETLOCKING_BYCALLER);
|
__fsetlocking (f, FSETLOCKING_BYCALLER);
|
||||||
fprintf (f, "<%d>", pri);
|
fprintf (f, "<%d>", pri);
|
||||||
(void) time (&now);
|
now = time (NULL);
|
||||||
f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr,
|
f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr,
|
||||||
f->_IO_write_end
|
f->_IO_write_end
|
||||||
- f->_IO_write_ptr,
|
- f->_IO_write_ptr,
|
||||||
|
@ -30,7 +30,7 @@ strfry (char *string)
|
|||||||
{
|
{
|
||||||
static char state[32];
|
static char state[32];
|
||||||
rdata.state = NULL;
|
rdata.state = NULL;
|
||||||
__initstate_r (time ((time_t *) NULL) ^ getpid (),
|
__initstate_r (time (NULL) ^ getpid (),
|
||||||
state, sizeof (state), &rdata);
|
state, sizeof (state), &rdata);
|
||||||
init = 1;
|
init = 1;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,10 @@ __sleep (unsigned int seconds)
|
|||||||
|
|
||||||
recv = __mach_reply_port ();
|
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,
|
(void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
|
||||||
0, 0, recv, seconds * 1000, MACH_PORT_NULL);
|
0, 0, recv, seconds * 1000, MACH_PORT_NULL);
|
||||||
after = time ((time_t *) NULL);
|
after = time (NULL);
|
||||||
__mach_port_destroy (__mach_task_self (), recv);
|
__mach_port_destroy (__mach_task_self (), recv);
|
||||||
|
|
||||||
return seconds - (after - before);
|
return seconds - (after - before);
|
||||||
|
@ -219,7 +219,7 @@ __getdate_r (const char *string, struct tm *tp)
|
|||||||
return 7;
|
return 7;
|
||||||
|
|
||||||
/* Get current time. */
|
/* Get current time. */
|
||||||
time (&timer);
|
timer = time (NULL);
|
||||||
__localtime_r (&timer, &tm);
|
__localtime_r (&timer, &tm);
|
||||||
|
|
||||||
/* If only the weekday is given, today is assumed if the given day
|
/* If only the weekday is given, today is assumed if the given day
|
||||||
|
@ -10,7 +10,7 @@ main (int argc, char *argv[])
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
time (&t);
|
t = time (NULL);
|
||||||
tp = gmtime (&t);
|
tp = gmtime (&t);
|
||||||
|
|
||||||
n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
|
n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
|
||||||
|
Loading…
Reference in New Issue
Block a user