This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Re: [commit] Re: [PATCH] Avoid potencially-stale errno usage
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 11 Apr 2013 08:38:15 +0200
- Subject: [patch] Re: [commit] Re: [PATCH] Avoid potencially-stale errno usage
- References: <CAL8qUbrD=fgMP7nE0O8tX=AXifUpQXas25o_4SfK4p79rfoUpw at mail dot gmail dot com> <CAL8qUbqjtBKJFJZ6dPS78Zh8Eb3b33U9JXTmn1pS3Le93xt7Rw at mail dot gmail dot com> <20130325195832 dot GA15218 at host2 dot jankratochvil dot net> <515478BE dot 3030801 at redhat dot com> <51630502 dot 3050109 at redhat dot com> <20130408183434 dot GA32515 at host2 dot jankratochvil dot net> <5164075E dot 8000607 at redhat dot com>
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 <jan.kratochvil@redhat.com>
* 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. */