From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GNHwG/cZm2MsZgEAWB0awg (envelope-from ) for ; Thu, 15 Dec 2022 07:58:31 -0500 Received: by simark.ca (Postfix, from userid 112) id 6DB6E1E128; Thu, 15 Dec 2022 07:58:31 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ZjZ5LgZP; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E126E1E124 for ; Thu, 15 Dec 2022 07:58:30 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCDD1388DD51 for ; Thu, 15 Dec 2022 12:58:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCDD1388DD51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671109107; bh=iblk1QAr50ai6QudgV/xNTT8GmDW5hjzSroxlSKVrhQ=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZjZ5LgZPQ2WgP+23+9xobIW66XgNY69WDCdwZ3pw3MQsELzrP9s51hkqMI/3VRBAa SJvxLZI1mhTLyqOvJm0oRsXGzoWN/WYBahSTAmYoaRSEacYPwo84bGnxiLLHv9A45E 4NIP/uvg0JeAQvAelui5rZfL6KYsg0VyLNlnlyXY= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 7611B388CF08 for ; Thu, 15 Dec 2022 12:58:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7611B388CF08 Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0F98B1E112; Thu, 15 Dec 2022 07:58:07 -0500 (EST) Message-ID: <2d9e0814-b4a8-fba8-9422-a1c746a15ebf@simark.ca> Date: Thu, 15 Dec 2022 07:58:06 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PUSHED] gdb: make more use of make_target_connection_string To: Andrew Burgess , gdb-patches@sourceware.org References: <53cf95c3389a3ecd97276d322e4a60fe3396a201.1671108652.git.aburgess@redhat.com> Content-Language: en-US In-Reply-To: <53cf95c3389a3ecd97276d322e4a60fe3396a201.1671108652.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 12/15/22 07:53, Andrew Burgess via Gdb-patches wrote: > Oops! I accidentally pushed this patch to master. > > I haven't immediately reverted it because I think it is a pretty > obvious cleanup, but I would normally have posted this for review. > > If anyone has any issues with the patch then please reply, I can > either fix any problems, or fully revert the patch if requeted. > > Sorry for the carelessness. > > Thanks, > Andrew I just spotted some nits, if you want to fix them up. > diff --git a/gdb/inferior.c b/gdb/inferior.c > index ec63e0491e5..3d2bce9df7b 100644 > --- a/gdb/inferior.c > +++ b/gdb/inferior.c > @@ -33,6 +33,7 @@ > #include "cli/cli-utils.h" > #include "arch-utils.h" > #include "target-descriptions.h" > +#include "target-connection.h" > #include "readline/tilde.h" > #include "progspace-and-thread.h" > #include "gdbsupport/buildargv.h" > @@ -482,21 +483,13 @@ static std::string > uiout_field_connection (process_stratum_target *proc_target) > { > if (proc_target == NULL) > - { > - return {}; > - } > - else if (proc_target->connection_string () != NULL) > - { > - return string_printf ("%d (%s %s)", > - proc_target->connection_number, > - proc_target->shortname (), > - proc_target->connection_string ()); > - } > + return {}; > else > { > - return string_printf ("%d (%s)", > - proc_target->connection_number, > - proc_target->shortname ()); > + std::string conn_str > + = make_target_connection_string (proc_target).c_str (); I think you can remove the .c_str here. > diff --git a/gdb/target-connection.c b/gdb/target-connection.c > index d1da6a2d7b9..d88b9c8f563 100644 > --- a/gdb/target-connection.c > +++ b/gdb/target-connection.c > @@ -91,10 +91,7 @@ print_connection (struct ui_out *uiout, const char *requested_connections) > > process_stratum_target *t = it.second; > > - size_t l = strlen (t->shortname ()); > - if (t->connection_string () != NULL) > - l += 1 + strlen (t->connection_string ()); > - > + size_t l = strlen (make_target_connection_string (t).c_str ()); I think you can use std::string::length here. Simon