From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 815 invoked by alias); 11 Apr 2013 06:38:22 -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 765 invoked by uid 89); 11 Apr 2013 06:38:22 -0000 X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 11 Apr 2013 06:38:21 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3B6cKDW006096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Apr 2013 02:38:20 -0400 Received: from host2.jankratochvil.net (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3B6cGbI015489 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 11 Apr 2013 02:38:18 -0400 Date: Thu, 11 Apr 2013 12:53:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: [patch] Re: [commit] Re: [PATCH] Avoid potencially-stale errno usage Message-ID: <20130411063815.GA28346@host2.jankratochvil.net> References: <20130325195832.GA15218@host2.jankratochvil.net> <515478BE.3030801@redhat.com> <51630502.3050109@redhat.com> <20130408183434.GA32515@host2.jankratochvil.net> <5164075E.8000607@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5164075E.8000607@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-04/txt/msg00316.txt.bz2 On Tue, 09 Apr 2013 14:19:42 +0200, Pedro Alves wrote: > +static void > +unpush_and_perror (const char *string) > +{ > + char *errstr; > + > + errstr = xstrprintf ("%s: %s", string, safe_strerror (errno)); > + make_cleanup (xfree, errstr); > + > + remote_unpush_target (); > + throw_error (TARGET_CLOSE_ERROR, "%s", errstr); > +} It has changed the output message: 20130409Build-gdbcvs-dwarf41-gcchead-f19/fedora-19-x86_64/out/gdb-m32.log:Remote communication error. Target disconnected.: Connection reset by peer. 20130410Build-gdbcvs-dwarf41-gcchead-f19/fedora-19-x86_64/out/gdb-m64.log:Remote communication error. Target disconnected.: Connection reset by peer Formerly: throw_perror_with_name (enum errors errcode, const char *string) { [...] throw_error (errcode, _("%s."), combined); } Instead of changing the testsuite expectation in 2a9030220efff2f7e5e7447ee523726bd9585072 I find better to retain the backward compatibility, although it is sure a nitpick. Also I have simplified the code a bit. Thanks, Jan gdb/ 2013-04-11 Jan Kratochvil * remote.c (unpush_and_perror): Add output message final dot. diff --git a/gdb/remote.c b/gdb/remote.c index de075c8..f0dbba6 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7036,18 +7036,17 @@ remote_files_info (struct target_ops *ignore) /* Close/unpush the remote target, and throw a TARGET_CLOSE_ERROR error to higher layers. Called when a serial error is detected. The exception message is STRING, followed by a colon and a blank, - then the system error message for errno at function entry. */ + the system error message for errno at function entry and final dot + for output compatibility with throw_perror_with_name. */ static void unpush_and_perror (const char *string) { - char *errstr; - - errstr = xstrprintf ("%s: %s", string, safe_strerror (errno)); - make_cleanup (xfree, errstr); + int saved_errno = errno; remote_unpush_target (); - throw_error (TARGET_CLOSE_ERROR, "%s", errstr); + throw_error (TARGET_CLOSE_ERROR, "%s: %s.", string, + safe_strerror (saved_errno)); } /* Read a single character from the remote end. */