From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39486 invoked by alias); 23 Oct 2018 21:59:32 -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 39472 invoked by uid 89); 23 Oct 2018 21:59:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=BAYES_20,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=HIronPort-PHdr:9a23, HIronPort-PHdr:sk:ipTpvws, HIronPort-PHdr:sk:mATRIyK, HIronPort-PHdr:MK994N9 X-HELO: mailsec109.isp.belgacom.be Received: from mailsec109.isp.belgacom.be (HELO mailsec109.isp.belgacom.be) (195.238.20.105) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Oct 2018 21:59:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1540331968; x=1571867968; h=message-id:subject:from:to:date:in-reply-to:references: mime-version:content-transfer-encoding; bh=eb/BLRAlkAhdC2RzJNod5xHfht6mql99pgamFUwptck=; b=Gi0sNKb/I5aP9Lu9WyvyY9stx+aH8439jSEBISdWryoZz/+CEmmW6M9Y d+B/aeYk5zVm+J88u2FnKWlTO6RiFQ==; Received: from unknown (HELO md) ([109.129.148.150]) by relay.skynet.be with ESMTP/TLS/AES256-GCM-SHA384; 23 Oct 2018 23:59:26 +0200 Message-ID: <1540331965.12106.8.camel@skynet.be> Subject: Re: [RFAv3 1/5] New cli-utils.h/.c function extract_info_print_args From: Philippe Waroquiers To: Pedro Alves , gdb-patches@sourceware.org Date: Tue, 23 Oct 2018 21:59:00 -0000 In-Reply-To: References: <20180923214209.985-1-philippe.waroquiers@skynet.be> <20180923214209.985-2-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00527.txt.bz2 On Mon, 2018-10-22 at 15:15 +0100, Pedro Alves wrote: > Hi Philippe, > > Finally managed to read through the series. > > I have a few comments throughout the series, but nothing very serious. Thanks for the comments, I will submit a new version soon (once I have double checked I properly handled all the comments). One question below ... > +/* See documentation in cli-utils.h. */ > > + > > +const char* > > +info_print_args_help (const char* prefix, > > + const char* entity_kind) > While at it, why return a copy of the string, instead of returning > the std::string directly? The returned value is used as argument to add_prefix_cmd, that expects a char * that must stay valid when the std::string is destroyed. So, at the call site, I cannot use info_print_args_help (...).c_str (), as this gives a memory corruption (confirmed by valgrind). So, I have done: +const char * +info_print_args_help (const char *prefix, +                     const char *entity_kind) +{ +  /*  Note : this returns a string allocated with xstrdup, as this +      is typically used as argument to add_prefix_cmd, which needs a +      string that stays valid after destruction of the std::string.  */ +  return xstrdup +    (string_printf (_("\ +%sIf NAMEREGEXP is provided, only prints the %s whose name\n   \ .... Does this sound ok, or is there a better way to do (e.g. at the call site) ? Thanks Philippe