From: Alexander Monakov <amonakov@ispras.ru>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Handle localtime errors in ctime
Date: Thu, 15 Jun 2017 20:46:18 +0300 (MSK) [thread overview]
Message-ID: <alpine.LNX.2.20.13.1706152038570.13954@monopod.intra.ispras.ru> (raw)
In-Reply-To: <20170615173109.GS1627@brightrain.aerifal.cx>
On Thu, 15 Jun 2017, Rich Felker wrote:
> Look ok?
>
> diff --git a/src/time/ctime_r.c b/src/time/ctime_r.c
> index d2260a1..05699ca 100644
> --- a/src/time/ctime_r.c
> +++ b/src/time/ctime_r.c
> @@ -3,6 +3,5 @@
> char *ctime_r(const time_t *t, char *buf)
> {
> struct tm tm;
> - localtime_r(t, &tm);
> - return asctime_r(&tm, buf);
> + return localtime_r(t, &tm) ? asctime_r(&tm, buf) : 0;
> }
Sure, although personally I'm highly tempted to pick up the size optimization
from reusing return value of localtime_r:
Alexander
diff --git a/src/time/ctime_r.c b/src/time/ctime_r.c
index d2260a16..9047b38f 100644
--- a/src/time/ctime_r.c
+++ b/src/time/ctime_r.c
@@ -2,7 +2,6 @@
char *ctime_r(const time_t *t, char *buf)
{
- struct tm tm;
- localtime_r(t, &tm);
- return asctime_r(&tm, buf);
+ struct tm tm, *tm_p;
+ return (tm_p = localtime_r(t, &tm)) ? asctime_r(tm_p, buf) : 0;
}
next prev parent reply other threads:[~2017-06-15 17:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 16:43 Omer Anson
2017-06-15 16:54 ` Rich Felker
2017-06-15 17:03 ` Alexander Monakov
2017-06-15 17:06 ` Rich Felker
2017-06-15 17:19 ` Alexander Monakov
2017-06-15 17:26 ` Rich Felker
2017-06-15 17:31 ` Rich Felker
2017-06-15 17:46 ` Alexander Monakov [this message]
2017-06-21 0:34 ` Rich Felker
2017-06-21 7:18 ` Alexander Monakov
2017-06-21 14:47 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.20.13.1706152038570.13954@monopod.intra.ispras.ru \
--to=amonakov@ispras.ru \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).