This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 3/8] Use std::string in utils.c
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Tue, 3 Oct 2017 11:50:05 +0100
- Subject: Re: [RFA 3/8] Use std::string in utils.c
- Authentication-results: sourceware.org; auth=none
- 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 at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3236C8765C
- References: <20171001040643.25162-1-tom@tromey.com> <20171001040643.25162-4-tom@tromey.com>
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" : "");
>