From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id B36273858D28 for ; Fri, 22 Dec 2023 15:32:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B36273858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B36273858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703259159; cv=none; b=vcJusS2lqJWr7QXEgVBswDosI4FBgOezDcgJSTiG0xOHRBM6eiSkNpK29Eaw9jneAxSpuWvEceIZSONGy42oFBigx364elKS3AnuBBTMxib7cy0Fr3M5pR2InyNlblK6wvMI+gla+c1Dpajv0WRG82VCC32yLrEkeKzUWAEqVRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703259159; c=relaxed/simple; bh=YImUKRnxv5/PInhsYAU7MQ/tP0+J9lvYyUl+XiIPj+4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dkvK3dAKFPu0qAace9Afk19kDiOBauUeqySUQ/DJxzQdU8weYMQKdn1oVg2eJBJF+Nf73JloQVmVZItZOILYogDLUiTmm3EAzbr6kf7kWEdEXunevNFcdhYq7vgSW7f9e92J7KtTKoG+lX9xeXr1cMctp22Z/tOIFBpvXL1X3FQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTPS id GbO0rp5yDgpyEGhVtrs6DT; Fri, 22 Dec 2023 15:32:37 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id GhVsrZgy8AKScGhVsr85dY; Fri, 22 Dec 2023 15:32:37 +0000 X-Authority-Analysis: v=2.4 cv=N6w6qkxB c=1 sm=1 tr=0 ts=6585ac15 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=e2cXIFwxEfEA:10 a=Qbun_eYptAEA:10 a=20KFwNOVAAAA:8 a=NhO-mLM1--e09cSgWIwA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wUBqrXmPPxHNxL17aG/csggBJ2RjPdjFFFMgYuqKzbs=; b=M9dgUOHvYliJmXoFECifDlM4cL Qk0+ZOCHckYK7xcGqP7+Nft8Vs7FYcHE+DHZ/VZwKaqU49qcXLDpFvJrtGo6pd5dYUa+WQyurlinD D8PBGfsN8l+uo+BruKN+nIamM; Received: from 71-211-161-25.hlrn.qwest.net ([71.211.161.25]:35466 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rGhVs-002SV5-18; Fri, 22 Dec 2023 08:32:36 -0700 From: Tom Tromey To: Alexandra =?utf-8?B?SMOhamtvdsOh?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] remote.c: Make packet_check_result return a structure References: <20231222113359.1224157-1-ahajkova@redhat.com> X-Attribution: Tom Date: Fri, 22 Dec 2023 08:32:35 -0700 In-Reply-To: <20231222113359.1224157-1-ahajkova@redhat.com> ("Alexandra =?utf-8?B?SMOhamtvdsOhIidz?= message of "Fri, 22 Dec 2023 12:33:59 +0100") Message-ID: <87il4q2qy4.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.161.25 X-Source-L: No X-Exim-ID: 1rGhVs-002SV5-18 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-161-25.hlrn.qwest.net (murgatroyd) [71.211.161.25]:35466 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfO7V6zeVhBSiYRLe+QXgmlu87FYzjwtr6M1bgd+Xm/mNLbKsK3s/mKWy58yncsn+vScEKTgqDhzxVUCaICgGNHOI/n+D5b2e6kCeDchGnCm60BmdXL07 3k3Fi52wLT6X34FrHuFnWKgUU4EXxTZ8wXsnUl/lkfqTb2WnrU4U7aGcixIRoICjVzJl3MLx5ql7q1g0NC6KHohtQk2WMPWNS9E= X-Spam-Status: No, score=-3016.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "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 PAC= KET_ERROR, Alexandra> + err_msg contains an error message string from E.string or th= e number Alexandra> + stored as a string from E.num. */ Alexandra> +struct packet_result Alexandra> +{ Alexandra> + packet_result (enum packet_status status, std::string err_msg) 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". 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