From nobody Tue Feb 10 03:39:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1770119664; cv=none; d=zohomail.com; s=zohoarc; b=SpfX/DXFQysOtLaiKNVlltAowwVZ9MtEgTlx8XLYo50UTgUyeU38pg+S2IUyXH5/6ytulyl6PAfaaMda4LwGTZTJgYXXfffXGLPmD0eSjTUx7u8TObk+O+FtRsLBdgo8FgpwfikTVHkZe0ch93slcGu5WgYDcceJSLWx5hOtG8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770119664; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gmAQhMQ8vyDaeIAxAhsnVaQsmiKDf2EhtEVKbz4JjHE=; b=m2q//cuYOW41X9czftt8UqjyCQSudrjti5QahHfnwqJNM+M6fKiImlYttydqsG8/S8jdy+htXezRZJ/X3T78jqxx4LSPbKD8H0QA96+oOHnQmZuhITXKTIK3RYpugfXqkkSq6ebZTiotStFaLnqGeFxcjOSnHvl5GFff/KgRpaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17701196644561021.8724007225445; Tue, 3 Feb 2026 03:54:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vnExQ-0008FI-Dq; Tue, 03 Feb 2026 06:52:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vnEx2-0007vA-QN for qemu-devel@nongnu.org; Tue, 03 Feb 2026 06:52:12 -0500 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vnEx0-000593-74 for qemu-devel@nongnu.org; Tue, 03 Feb 2026 06:52:12 -0500 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-6580dbdb41eso8374768a12.0 for ; Tue, 03 Feb 2026 03:52:08 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-658b4256949sm9087243a12.6.2026.02.03.03.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 03:52:03 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 51E4A5FAED; Tue, 03 Feb 2026 11:52:02 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1770119527; x=1770724327; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gmAQhMQ8vyDaeIAxAhsnVaQsmiKDf2EhtEVKbz4JjHE=; b=TFDR7sju0zE0PuoNSu/uMyxJYYMJidotjG7VTJ3GT8Cx992GS1H9UjyF5C5gtyaXHZ VzF6aaakBZU0Gh2x0MC+GvhOm0t/SQofefNILNYwdYwQ3DxnnlS0rnQh8Z5zOdjsyQWs Wrs/O0AIcIX3IJ5riw/+yl6u7TQAzEUY0aXqVQatSgapoWqDy59NvESTFDhm8vP0+ORZ 2WKJXI1LfjM+llPywJgqxkbpt3oGWvGOVRniye/uqC9KD/bo8C2c0QVE5ihPgQEATppA LaDG91a6A9lmZcu9NgdXCjq0/N/nIydqnTVpezNW2lGue4QW+NccvhRC6+qklb7vPZlH mU3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770119527; x=1770724327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gmAQhMQ8vyDaeIAxAhsnVaQsmiKDf2EhtEVKbz4JjHE=; b=rokyZEYo6OJMgkXKIlMARvCHYxlW/YkmEJUiT2wIlLVc1WfvOOxrjTTW+XRmHUcl8c gmwNIEFB38dhIkJO580nYvtGldS8NlYOsE4x1NgClbP42IgBVrTxwtVotCWvfY4wfCJl djUrg7HUUpdcs9ZuwiIubpjtZRjchYYLiTqvYpLCSwOuVXdMoDpfDj3DUf31FgGLwqjJ s5Uw5WV6O2IFaCcZuyDJRtYxuGL2J9VsjdOWWwo/AIAJNERGhhBMUegY9lCfk8bK0iuf mq7eWtYZ2X4uAjOleyexI0tVQZsfmVl/CRUNyQ9IsYEfHqrUXMHM5x0a4O9AMRMntBCD HIWQ== X-Gm-Message-State: AOJu0YzfiW4pDiVFUi1h2NM3xxxNsjAZgo797GACtYBTF55s15vWhKE2 V8lKA0ZNTItMFgPMDHZoxAnl8GLyCxPJPGEV+5SaF3cXTtL81e8HlnB/+06MoqjWLqo= X-Gm-Gg: AZuq6aLYCe2w61olFSx4DJcagXf4DIveJ/h/pRxgMEP6u0GehjuoS6eVvyRUvYrriSs zmvuJwZibck8yTRqMWoBOknSOGhK5jdOH1VDzh/5A/6rChn6AbujoUZOwrz6KLRIviLwjUVxQB7 5qERj+j9ppqkYMmwQbiZDULy9f6ERHneOxG/r1e5Ta/a9tBzrHzkgCpXvpj2Qvq/K5OrH2C0RWG 0+EkZAQz6jnk/qzJ4CuYpKpnWOBvUg+ZWB7oAEdnj3FGZqFk0bP7upH+JjHJbD2zggs2krHgyh/ bgXyEWpv0S8CTXEeOxbP0XpeMSvlNFBhIZV9A2wxcxB0aLok8YqOcTZ2rMlvyackE9lWT23IVm7 YscbK/xLSP2Jsaf78Ig8wVdnl3kjjWJZDmzdIbMe8ezZnRIf9NdS7BdIvODAun0jXd2b+YUC027 xCM7GSVbx8px+U9h5ee7c6Kg== X-Received: by 2002:a05:6402:538c:b0:659:389c:a0fc with SMTP id 4fb4d7f45d1cf-659389ca359mr909932a12.27.1770119527298; Tue, 03 Feb 2026 03:52:07 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: John Snow , Pierrick Bouvier , qemu-arm@nongnu.org, Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Nicholas Piggin , Wainer dos Santos Moschetta , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell , Cleber Rosa , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Edgar E. Iglesias" , qemu-s390x@nongnu.org, Thomas Huth , Paolo Bonzini , Akihiko Odaki , Daniel Henrique Barboza , David Hildenbrand , Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PATCH 03/11] gdbstub: remove the need for goto cleanup Date: Tue, 3 Feb 2026 11:51:53 +0000 Message-ID: <20260203115201.2387721-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260203115201.2387721-1-alex.bennee@linaro.org> References: <20260203115201.2387721-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1770119665575158500 We already set a default error reply which we can only overwrite if we successfully follow the chain of checks. Initialise the variables as NULL and use that to gate the construction of the filled out stop/reply packet. Signed-off-by: Alex Benn=C3=A9e --- gdbstub/gdbstub.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 1f8cd118924..d4db7ba30cc 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1413,36 +1413,32 @@ static void handle_v_cont(GArray *params, void *use= r_ctx) =20 static void handle_v_attach(GArray *params, void *user_ctx) { - GDBProcess *process; - CPUState *cpu; + GDBProcess *process =3D NULL; + CPUState *cpu =3D NULL; =20 + /* Default error reply */ g_string_assign(gdbserver_state.str_buf, "E22"); - if (!params->len) { - goto cleanup; - } - - process =3D gdb_get_process(gdb_get_cmd_param(params, 0)->val_ul); - if (!process) { - goto cleanup; + if (params->len) { + process =3D gdb_get_process(gdb_get_cmd_param(params, 0)->val_ul); } =20 - cpu =3D gdb_get_first_cpu_in_process(process); - if (!cpu) { - goto cleanup; + if (process) { + cpu =3D gdb_get_first_cpu_in_process(process); } =20 - process->attached =3D true; - gdbserver_state.g_cpu =3D cpu; - gdbserver_state.c_cpu =3D cpu; + if (cpu) { + process->attached =3D true; + gdbserver_state.g_cpu =3D cpu; + gdbserver_state.c_cpu =3D cpu; =20 if (gdbserver_state.allow_stop_reply) { g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNA= L_TRAP); gdb_append_thread_id(cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); gdbserver_state.allow_stop_reply =3D false; -cleanup: - gdb_put_strbuf(); } + + gdb_put_strbuf(); } =20 static void handle_v_kill(GArray *params, void *user_ctx) --=20 2.47.3