From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id 7BDB93858D28 for ; Mon, 28 Aug 2023 17:51:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BDB93858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4RZJ631q5Pz4St9; Mon, 28 Aug 2023 17:51:55 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RZJ630ftyz3S4W; Mon, 28 Aug 2023 17:51:55 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693245115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DbmxnfaEDrhxTu2FN4kwJimhDIiygK7sILUZOMG7Igw=; b=pX9wN7H1FVXC8XZ/JRkwIW2vnx1ihA3VRcNEgGK8t+PNli06nzvqViz+Hhfhmv1C1aLIFx 3vtGIKQsUueOBUMAjYPOZRVJn808DNeioncXFxm26S/wxHbX+56MYqjQHm9dnP0imLc/jl af53uA0ZJcykZthvOegCE4okhEIqAXfFk64BPMYcx6mNpggIg7OMgpm+s1l3TJKIIkzjwT fW2XnHhuaudjoaFCO/+6N8l9ctakf9GnkM5GZEdF0bZuQT32ijzNJXvQ8N83JwOC9zb3hS SCqBDw9G0AMVKjKzrW1lGdJgKyhB6GvF6FDPWn8BjoR2hn+qrOrH1r5piAXuIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693245115; a=rsa-sha256; cv=none; b=K62sGAm1CTwdps8cWWnFTSPg4eKot/OlWdNBl2Oir1AdoK8A6/2ls5IBwiAuIvJ27wTSGR MUQKwXhZBCADeRzxnPOxcb89dR0YDWyQZtbeFwZ3xjHsq8aOcdnmIc0135ZsvCKGFIluyX mvcoXJBqbD/mYJYny4lvfzFucJ1ocgANQkse3KmeZYlY6hCuBLuzvD3pRU7uJVGRUAC3qD VHkHnWG/OGpY6DpfVaPGYsEMWAGrqDBW1KAWi4h8p7IVnjwbAXEvbRYSeKujEHP9qdS7/K OdxYlVdZfGulzZfpyF+/5eAz8syKUA8Jkqn1f7umTYyCklYdiSc+qvr1Zb8K5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693245115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DbmxnfaEDrhxTu2FN4kwJimhDIiygK7sILUZOMG7Igw=; b=Ba+6iJCpz8gnk3xz3FU9FVwWz/fNxM2KsdbbW++Ur4ZEuaVTSPMpHKvbGBphtXQyQIdEmw aKCs/g/JZdQAy+zie8eWiYSXeOEvYTYJzgQkihX8Fs63c3eaHR3ZPmWx6fBx3kE2bK7gfX U3NQl4SS3gZ6DiCVcfLM6I6q1GANKq61OdF94LZBdizsz8nXLobTQbQiVFyhvzuHxgf2qt TS+sXPxB+JrQsz9CLHoxkbxkp8fmcLvHyy+aMC5kifrEpb8PJ6CuiWO383WeLqW1OA3p61 C/5nf75GaOgrf8dy6bis0jAZCmZqu33VsX2/0mrIfZElsYbIBWSuXejQVU0udg== Received: from [IPV6:2601:648:8683:a9e0:3858:44e8:8d12:eaf0] (unknown [IPv6:2601:648:8683:a9e0:3858:44e8:8d12:eaf0]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RZJ624xTtzBH1; Mon, 28 Aug 2023 17:51:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <0451edf2-c709-9e97-5145-1b07653cda9b@FreeBSD.org> Date: Mon, 28 Aug 2023 10:51:53 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20230828-getpkt-cleanup-v1-0-0f3da220530c@adacore.com> From: John Baldwin Subject: Re: [PATCH 0/4] Unify getpkt methods in remote.c In-Reply-To: <20230828-getpkt-cleanup-v1-0-0f3da220530c@adacore.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,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 8/28/23 10:14 AM, Tom Tromey via Gdb-patches wrote: > This series unifies the various getpkt methods in remote.c, and > applies a little bit of bool-ification as well. > > --- > Tom Tromey (4): > Remove getpkt_sane > Remove expecting_notif parameter from getpkt_or_notif_sane_1 > Use bool in getpkt > Unify getpkt and getpkt_or_notif_sane > > gdb/remote.c | 242 +++++++++++++++++++++++++---------------------------------- > 1 file changed, 103 insertions(+), 139 deletions(-) > --- > base-commit: b8a175b415454df6a039ba0b5d2ff13c3c180275 > change-id: 20230828-getpkt-cleanup-126c625821bf > > Best regards, These all look fine to me. My only thought was if you wanted to make use of a default value for the 'forever' argument, or perhaps have a 'getpkt_wait' wrapper. My one worry about bool arguments to functions (in general) is that true/false often do not convey obvious meaning in context. One way to deal with this can be to use dedicated enums, e.g.: enum getpkt_forever { NON_BLOCKING, BLOCKING } so that the invocations have more obvious intent. However, reading the patch 3 in particular, it seems like the vast majority of getpkt calls end up passing false, so I wonder if you might not like to end up with something like this at the end: int getpkt_1 (gdb::char_vector *buf, bool forever, bool *is_notif); int getpkt (gdb::char_vector *buf, bool *is_notif = nullptr) { return getpkt_1 (buf, false, is_notif); } int getpkt_wait (gdb::char_vector *buf, bool *is_notif = nullptr) { return getpkt_1 (buf, true, is_notif); } Maybe you could get by with defaulting both arguments to getpkt and not needing getpkt_1 at all, just having getpkt_wait() as wrapper? I think that might end up being more readable as in many cases in the resulting code you'd end up with: putpkt (""); getpkt (&rs->buf); (You could also call the wrapper `getpkt_forever` if that seems like a better name.) -- John Baldwin