Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: "Christian Biesinger \(Code Review\)"
	<gerrit@gnutoolchain-gerrit.osci.io>
Cc: Christian Biesinger <cbiesinger@google.com>, 	gdb-patches@sourceware.org
Subject: Re: [review v2] Use ctime_r and localtime_r if available
Date: Sun, 03 Nov 2019 07:20:00 -0000	[thread overview]
Message-ID: <87pni9h1e3.fsf@hase.home> (raw)
In-Reply-To: <20191103025430.BD90720AF6@gnutoolchain-gerrit.osci.io>	(Christian Biesinger's message of "Sat, 2 Nov 2019 22:54:30 -0400")

On Nov 02 2019, Christian Biesinger (Code Review) wrote:

> diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
> index 67f9f3a..e0bad81 100644
> --- a/gdb/nat/linux-osdata.c
> +++ b/gdb/nat/linux-osdata.c
> @@ -912,7 +912,13 @@
>      {
>        time_t t = (time_t) seconds;
>  
> -      strncpy (time, ctime (&t), maxlen);
> +      char buf[30];
> +#ifdef HAVE_CTIME_R
> +      const char *time_str = ctime_r (&t, buf);
> +#else
> +      const char *time_str = ctime (&t);
> +#endif

buf is unused if !HAVE_CTIME_R.

Note that both ctime and ctime_r are obsolescent and should be replaced
by strftime.  gdb currently doesn't setlocale LC_TIME, but if it does it
would make the use of these functions undefined.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


  reply	other threads:[~2019-11-03  7:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 21:06 [review] " Christian Biesinger (Code Review)
2019-10-31 21:15 ` Christian Biesinger (Code Review)
2019-11-03  2:54 ` Christian Biesinger (Code Review)
2019-11-03  2:54 ` [review v2] " Christian Biesinger (Code Review)
2019-11-03  7:20   ` Andreas Schwab [this message]
2019-11-03 20:09     ` Christian Biesinger via gdb-patches
2019-11-03 20:04 ` [review v3] " Christian Biesinger (Code Review)
2019-11-06 20:30 ` Christian Biesinger (Code Review)
2019-11-08 14:09   ` Pedro Alves
2019-11-08 17:11     ` Christian Biesinger via gdb-patches
2019-11-09 20:18       ` Christian Biesinger via gdb-patches
2019-11-10  7:38 ` Kevin Buettner (Code Review)
2019-11-10  7:45 ` Kevin Buettner (Code Review)
2019-11-11 22:22 ` [review v4] " Christian Biesinger (Code Review)
2019-11-11 22:27 ` [review v5] Use ctime_r and localtime_r for threadsafety Christian Biesinger (Code Review)
2019-11-11 22:29 ` Christian Biesinger (Code Review)
2019-11-12 20:21 ` Kevin Buettner (Code Review)
2019-11-15 19:50 ` [review v6] " Christian Biesinger (Code Review)
2019-11-15 19:52 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-16 22:07 ` [review v6] " Christian Biesinger (Code Review)

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=87pni9h1e3.fsf@hase.home \
    --to=schwab@linux-m68k.org \
    --cc=cbiesinger@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=gerrit@gnutoolchain-gerrit.osci.io \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox