From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99556 invoked by alias); 3 Oct 2017 10:50:09 -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 99539 invoked by uid 89); 3 Oct 2017 10:50:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=bare 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; Tue, 03 Oct 2017 10:50:08 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3236C8765C; Tue, 3 Oct 2017 10:50:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3236C8765C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CA8E60E3A; Tue, 3 Oct 2017 10:50:06 +0000 (UTC) Subject: Re: [RFA 3/8] Use std::string in utils.c To: Tom Tromey , gdb-patches@sourceware.org References: <20171001040643.25162-1-tom@tromey.com> <20171001040643.25162-4-tom@tromey.com> From: Pedro Alves Message-ID: <9df49461-5dfc-a954-e051-aaf7a3a862f2@redhat.com> Date: Tue, 03 Oct 2017 10:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20171001040643.25162-4-tom@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-10/txt/msg00029.txt.bz2 On 10/01/2017 05:06 AM, Tom Tromey wrote: > /* Don't allow infinite error/warning recursion. */ > { > @@ -429,18 +428,17 @@ internal_vproblem (struct internal_problem *problem, > char *msg; > > msg = xstrvprintf (fmt, ap); > - reason = xstrprintf ("%s:%d: %s: %s\n" > - "A problem internal to GDB has been detected,\n" > - "further debugging may prove unreliable.", > - file, line, problem->name, msg); > + reason = string_printf ("%s:%d: %s: %s\n" > + "A problem internal to GDB has been detected,\n" > + "further debugging may prove unreliable.", > + file, line, problem->name, msg); > xfree (msg); > - make_cleanup (xfree, reason); Could you please make msg use string_vprintf too while at it, thus getting rid of that bare xfree? (Similarly to the defaulted_query change below, though there we were using a cleanup.) Looks good to me with that change. Thanks, Pedro Alves > @@ -978,13 +975,12 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) > } > > /* Format the question outside of the loop, to avoid reusing args. */ > - question = xstrvprintf (ctlstr, args); > - old_chain = make_cleanup (xfree, question); > - prompt = xstrprintf (_("%s%s(%s or %s) %s"), > - annotation_level > 1 ? "\n\032\032pre-query\n" : "", > - question, y_string, n_string, > - annotation_level > 1 ? "\n\032\032query\n" : ""); > - make_cleanup (xfree, prompt); > + std::string question = string_vprintf (ctlstr, args); > + std::string prompt > + = string_printf (_("%s%s(%s or %s) %s"), > + annotation_level > 1 ? "\n\032\032pre-query\n" : "", > + question.c_str (), y_string, n_string, > + annotation_level > 1 ? "\n\032\032query\n" : ""); >