From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1671109087; bh=w/AXMhtS/H7ybCLSRaz0PMxztS0RFeQIBQ5JAArbpDw=; h=Date:Subject:To:References:From:In-Reply-To:From; b=q5m0PWiZuW0pYYtaflTGYaSOz9l8cE+oGt5xosCWtRi4hvBR2Ug6sfgo2WJEZnAX0 sNfTZI0w09jZGGyMXQ0S1gqTheYk0rQU4+uIux2+ggYDLeSvrZYsHcvDhpk+gIxJ+U OA/qNr5QK5bxxnDRGaKcPwc+J2WlciTUw7BW0Onw= 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 From: Simon Marchi In-Reply-To: <53cf95c3389a3ecd97276d322e4a60fe3396a201.1671108652.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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