From patchwork Wed Oct 19 01:12:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 16652 Received: (qmail 13307 invoked by alias); 19 Oct 2016 01:17:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 13208 invoked by uid 89); 19 Oct 2016 01:17:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Oct 2016 01:17:44 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E63FE3B72D for ; Wed, 19 Oct 2016 01:12:42 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9J1CJju019701 for ; Tue, 18 Oct 2016 21:12:42 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 25/31] Use ui_file_as_string in gdb/infrun.c Date: Wed, 19 Oct 2016 02:12:13 +0100 Message-Id: <1476839539-8374-26-git-send-email-palves@redhat.com> In-Reply-To: <1476839539-8374-1-git-send-email-palves@redhat.com> References: <1476839539-8374-1-git-send-email-palves@redhat.com> gdb/ChangeLog: yyyy-mm-yy Pedro Alves * infrun.c (print_target_wait_results): Use ui_file_as_string and std::string. --- gdb/infrun.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 2636a19..2fa6449 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3433,7 +3433,6 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, { char *status_string = target_waitstatus_to_string (ws); struct ui_file *tmp_stream = mem_fileopen (); - char *text; /* The text is split over several lines because it was getting too long. Call fprintf_unfiltered (gdb_stdlog) once so that the text is still @@ -3459,14 +3458,13 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, "infrun: %s\n", status_string); - text = ui_file_xstrdup (tmp_stream, NULL); + std::string text = ui_file_as_string (tmp_stream); /* This uses %s in part to handle %'s in the text, but also to avoid a gcc error: the format attribute requires a string literal. */ - fprintf_unfiltered (gdb_stdlog, "%s", text); + fprintf_unfiltered (gdb_stdlog, "%s", text.c_str ()); xfree (status_string); - xfree (text); ui_file_delete (tmp_stream); }