From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46006 invoked by alias); 3 Nov 2019 07:20:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 45995 invoked by uid 89); 3 Nov 2019 07:20:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:915 X-HELO: mail-out.m-online.net Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Nov 2019 07:20:24 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 475S4k0CBlz1qqkr; Sun, 3 Nov 2019 08:20:21 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 475S4j5M0lz1qqkQ; Sun, 3 Nov 2019 08:20:21 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 6LRVV5-_wpaL; Sun, 3 Nov 2019 08:20:21 +0100 (CET) Received: from hase.home (ppp-46-244-184-83.dynamic.mnet-online.de [46.244.184.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 3 Nov 2019 08:20:20 +0100 (CET) Received: by hase.home (Postfix, from userid 1000) id 2E3D5102190; Sun, 3 Nov 2019 08:20:20 +0100 (CET) From: Andreas Schwab To: "Christian Biesinger \(Code Review\)" Cc: Christian Biesinger , gdb-patches@sourceware.org Subject: Re: [review v2] Use ctime_r and localtime_r if available References: <20191103025430.BD90720AF6@gnutoolchain-gerrit.osci.io> X-Yow: Is this TERMINAL fun? Date: Sun, 03 Nov 2019 07:20:00 -0000 In-Reply-To: <20191103025430.BD90720AF6@gnutoolchain-gerrit.osci.io> (Christian Biesinger's message of "Sat, 2 Nov 2019 22:54:30 -0400") Message-ID: <87pni9h1e3.fsf@hase.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-11/txt/msg00055.txt.bz2 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."