From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36373 invoked by alias); 11 Jul 2018 12:55:17 -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 36359 invoked by uid 89); 11 Jul 2018 12:55:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=English, Espace, espace, tcp4 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jul 2018 12:55:15 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 872AE7A7F0; Wed, 11 Jul 2018 12:55:13 +0000 (UTC) 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 32E1F2166BA2; Wed, 11 Jul 2018 12:55:11 +0000 (UTC) Subject: Re: [PATCH v3] Implement IPv6 support for GDB/gdbserver To: Sergio Durigan Junior , GDB Patches References: <20180523185719.22832-1-sergiodj@redhat.com> <20180707204708.7171-1-sergiodj@redhat.com> Cc: Eli Zaretskii , Jan Kratochvil , Paul Fertser , Tsutomu Seki , Armand Scholtes From: Pedro Alves Message-ID: Date: Wed, 11 Jul 2018 12:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180707204708.7171-1-sergiodj@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-07/txt/msg00301.txt.bz2 Hi, This version looks mostly good to me. Only one thing raised my eyebrow. I also noticed a few typos here and there. See below. On 07/07/2018 09:47 PM, Sergio Durigan Junior wrote: > -/* Open a tcp socket. */ > +/* Try to connect to the host represented by AINFO. If the connection > + succeeds, return its socket. If we get a ECONNREFUSED error, > + return -1. Otherwise, return nothing. POLLS is used when > + 'connect' returns EINPROGRESS, and we need to invoke > + 'wait_for_connect' to obtain the status. */ > > -int > -net_open (struct serial *scb, const char *name) > +static gdb::optional > +try_connect (const struct addrinfo *ainfo, unsigned int *polls) > { I find this use of gdb::optional more confusing than helpful, since it creates multiple "levels" of places to check error. You have: #1 - empty optional, check errno for error [1] #2 - non-empty optional, value == -1, means ECONNREFUSED. #3 - non-empty optional, value is socket. ([1] the errno part is missing in the function's description) Above, #1 and #2 seem redundant? You can instead make the return type plain int, return -1 on all errors, and the caller can check errno for ECONNREFUSED. (If we were going to avoid errno, I think something like std::expected would be better than std/gdb::optional. std::optional for a type that already has a nullable state (in this case -1) tends to be confusing, IMO. See here for example: https://www.boost.org/doc/libs/1_61_0/libs/optional/doc/html/boost_optional/tutorial/when_to_use_optional.html ) Notice how your patch left this case incorrectly returning -1: if (n < 0) { /* A negative value here means that we either timed out or got interrupted by the user. Just return. */ close (sock); return -1; } > - if [target_info exists sockethost] { > + if { [info exists GDB_TEST_SOCKETHOST] } { > + # The user is not supposed to provide a port number, just a > + # hostname/address, therefore we add the trailing ":" here. > + set debughost "${GDB_TEST_SOCKETHOST}:" > + # Espace open and close square brackets. Typo: "Espace" -> "Escape" > +/* Initialized an unprefixed entry. In this case, we don't expect > + nothing on the 'struct addrinfo' HINT. */ > +#define INIT_UNPREFIXED_ENTRY(ADDR, EXP_HOST, EXP_PORT) \ > + INIT_ENTRY (ADDR, EXP_HOST, EXP_PORT, false, 0, 0, 0) Typo: "Initialized" -> "Initialize". Also, double negatives "don't expect nothing" don't work well in English. Do you mean "don't expect anything", or "expect nothing" ? (There's a difference: the former doesn't expect it but tolerates, the latter really requires nothing.) > + > +/* Initialized an unprefixed IPv6 entry. In this case, we don't > + expect nothing on the 'struct addrinfo' HINT. */ > +#define INIT_UNPREFIXED_IPV6_ENTRY(ADDR, EXP_HOST, EXP_PORT) \ > + INIT_ENTRY (ADDR, EXP_HOST, EXP_PORT, false, AF_INET6, 0, 0) Same comments apply here. > + > + /* IPv6, host and port present, no brackets. */ > + INIT_UNPREFIXED_ENTRY ("::1:1234", "::1", "1234"), > + /* IPv6, only host, no brackets. */ > + // INIT_UNPREFIXED_ENTRY ("::1", "::1", ""), Leftover, remove? > + /* IPv6, missing port, no brackets. */ > + INIT_UNPREFIXED_ENTRY ("::1:", "::1", ""), > + /* Prefixed "tcp4:" IPv4, host and port presents. */ Typo: "presents" -> "present". This appears in several places. Thanks, Pedro Alves