From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33316 invoked by alias); 11 Jul 2018 19:13:03 -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 33305 invoked by uid 89); 11 Jul 2018 19:13:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham 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 19:13:00 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E55D402332F; Wed, 11 Jul 2018 19:12:59 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ED3A10FFE4D; Wed, 11 Jul 2018 19:12:56 +0000 (UTC) From: Sergio Durigan Junior To: Pedro Alves Cc: GDB Patches , Eli Zaretskii , Jan Kratochvil , Paul Fertser , Tsutomu Seki , Armand Scholtes Subject: Re: [PATCH v3] Implement IPv6 support for GDB/gdbserver References: <20180523185719.22832-1-sergiodj@redhat.com> <20180707204708.7171-1-sergiodj@redhat.com> Date: Wed, 11 Jul 2018 19:13:00 -0000 In-Reply-To: (Pedro Alves's message of "Wed, 11 Jul 2018 13:55:11 +0100") Message-ID: <87k1q1twlj.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00320.txt.bz2 On Wednesday, July 11 2018, Pedro Alves wrote: > 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; > } No problem. I've changed the code to use plain int now. >> - 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" Fixed. >> +/* 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". Fixed. > 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.) We don't really care about HINT, so "don't expect anything" is the proper one to use here. Fixed. >> + >> +/* 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. Fixed. >> + >> + /* 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? Indeed, removed. >> + /* 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. Fixed all of them. I'll send a v4 soon. -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/