From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 009F83857C49 for ; Fri, 5 Jan 2024 14:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 009F83857C49 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 009F83857C49 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704465399; cv=none; b=QpQ7IaF/tGvjFnge5ZdOxibl8NFUOC7kC/Vhb/HwkUH3e0yofUpHs5bdTF6uirQXJu+zj6dJ/6VoVeVkaggew0cL2O7FH3jTjmuFVAZsysbfDEL9QSgKP+b68bxXXy2ipijn5RQWkfuqE5AD1v4oiDRw6Ttqi4+grFnUghQvsh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704465399; c=relaxed/simple; bh=gJkqDLx3c4AG6kzLu7t2DYLTGSvr9S5jhDyAGYgvv30=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ONt+/riyh9oCaWDWCxpFQ3xbcSVvczhdDfYJ14dCNxCH4+3/EOWENu7+wvsk3hiKmzySTjeo8bbrj5yhk6mBtQEgSEA6/R7nxKFZochWxsPNC2CIk7Lo0VB/cXMTsCJXGe1/ifauelw/b+kP8MDSspF5R6tVttNkAQ7JwEX04BA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704465396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OHaJCJdPb4rD+1d9YAvaQ9bRsR8nnOcuxu98e+PtkCc=; b=TNgx16Ht2KH23P6kCV7BrLqnyQsq1UnidfBYHAX2mBClN93QEGa0/9D3PnAgHX9/8esS4b N5FbChxzM48tpnRd6uO4RzsWAOiWf+02T2mrlR302+uQTUJNCT6OMcyi2irdKKR8M1e6EV d1ihHH1lDzaNTCCR63ln4iwjeotkFyk= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-qUUXwcrjNziTQ0plU1VOlQ-1; Fri, 05 Jan 2024 09:36:34 -0500 X-MC-Unique: qUUXwcrjNziTQ0plU1VOlQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a27619b3a46so76966066b.3 for ; Fri, 05 Jan 2024 06:36:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704465393; x=1705070193; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OHaJCJdPb4rD+1d9YAvaQ9bRsR8nnOcuxu98e+PtkCc=; b=BFFDePQPT5ZevvJGeBccJqi/AhsJZaD7NrU83HaIDgFOb+n0whhiQdnxCMxVw5aMEM +ile8x9Pg18gUh0fMgUil3iIppLfMDkrBME0E4FY7vUB11YSCb9LSg4JSV/Qf2BHsLxH bVOlk2suJ/ZZ9L5LePS54sdyiPWkttmH3pQ0VQyAeJMaVbETA0zwJi7pyc7RmSGcmE63 9IHV/b1FzyEZRq99unTQ1/s26sAAGA1Ei/v3pQPmoyifHlI+mSOZNfG6L5BQ9zSRa+E9 gjYcasQ1xnMP+tRm5I0xROdnEWfSRiTLKlHW0eUiEpDJqDKJsIPSl0/5b2lo9WOCmt2z Nzew== X-Gm-Message-State: AOJu0YxB+PZi6KNkvvtEZN05tA2qsSACpockFtNtVSvkE0NDVPwoJUCR qN+18WaSVm8Ip2ZMZP/4B6OBzRTFwo6SpQuoEaOC9PwshSWHnpEejhvRuf81Gbj9V3XabVIHIZX emxHBuE47YK4fypdrmBARrv5ucq8aUg== X-Received: by 2002:a17:906:f59e:b0:a28:d154:3754 with SMTP id cm30-20020a170906f59e00b00a28d1543754mr1561782ejd.130.1704465393739; Fri, 05 Jan 2024 06:36:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1qjnWQoGSEn8xmZr4HnXw+uvonpqgac+AnALOFPFHAO1a9AvECmymJdX9mTq7hlxihNIkgg== X-Received: by 2002:a17:906:f59e:b0:a28:d154:3754 with SMTP id cm30-20020a170906f59e00b00a28d1543754mr1561773ejd.130.1704465393384; Fri, 05 Jan 2024 06:36:33 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id d5-20020a170906640500b00a28a297d47esm935596ejm.73.2024.01.05.06.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 06:36:33 -0800 (PST) From: Andrew Burgess To: Tom Tromey , Alexandra =?utf-8?B?SMOhamtvdsOh?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] remote.c: Make packet_check_result return a structure In-Reply-To: <87il4q2qy4.fsf@tromey.com> References: <20231222113359.1224157-1-ahajkova@redhat.com> <87il4q2qy4.fsf@tromey.com> Date: Fri, 05 Jan 2024 14:36:32 +0000 Message-ID: <87y1d3979r.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: Tom Tromey writes: >>>>>> "Alexandra" =3D=3D Alexandra H=C3=A1jkov=C3=A1 = writes: > > Alexandra> packet_check_result currently returns an packet_result enum. > Alexandra> If GDB will recieve an error in a format E.errtext, which > Alexandra> is possible for some q packets, such errtext is lost if > Alexandra> treated by packet_check_result. > > Thank you for the patch. I think the general idea makes sense. > > Alexandra> There's no infrastructure to test this with a test case so > Alexandra> I tested this by modifying store_registers_using_G function > Alexandra> to get an error message: > > packet_check_result is isolated enough that, if you wanted, you could > write unit tests for it. > > Alexandra> +/* Keeps packet's return value. If packet's return value is P= ACKET_ERROR, > Alexandra> + err_msg contains an error message string from E.string or = the number > Alexandra> + stored as a string from E.num. */ > Alexandra> +struct packet_result > Alexandra> +{ > Alexandra> + packet_result (enum packet_status status, std::string err_m= sg) > Alexandra> + : m_status (status), > Alexandra> + m_err_msg (std::move (err_msg)) > > This is formatted strangely. > > Alexandra> + packet_result (enum packet_status status) > Alexandra> + : m_status (status) > Alexandra> + { > Alexandra> + gdb_assert (status !=3D PACKET_ERROR); > > Here and elsewhere the "{" is indented too far. > Also, single-argument constructors should ordinarily be "explicit". OOI, wondering why you specifically call out single-argument constructors here? I was re-reading this page to refresh my knowledge of 'explicit': https://en.cppreference.com/w/cpp/language/explicit And it seems that marking multi-argument constructors would place the same restrictions on the constructor as for single-argument constructors... Though I guess there's more chance of accidentally assigning a scalar into a non-scalar object (e.g. packet_result in this case). Maybe that's why the single-argument case is being called out? Anyway, not disagreeing with you, just trying to educate myself. Thanks, Andrew > > Alexandra> + } > Alexandra> + > Alexandra> +private: > Alexandra> + enum packet_status m_status; > Alexandra> + std::string m_err_msg; > Alexandra> + > Alexandra> +public: > > Better IMO to put all the private stuff at the end. > > Alexandra> + enum packet_status > Alexandra> + status () const > > For methods this all goes on one line. > > Alexandra> -static enum packet_result > Alexandra> +static struct packet_result > > Since you're touching this anyway you might as well leave out the > 'struct' keyword. > > Tom