From nobody Mon Feb 9 05:20:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638543666; cv=none; d=zohomail.com; s=zohoarc; b=HGpAfBoKYfuWXucVV++eZjegG4gAg9PKTIPICh/GY22i3IB/kJePLjtygPKJniQ8lGBPdXFSQSFVplkFN5sit1eCgSqZeNAGIqY6OsZK8M5371W0Ca9+0pb91d4GUGR/Oe0nQflQPKdUCXgcxWDZJFROw4+f94xqBccOmN3TdMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543666; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ITx/BivkhRdHS4Yc2sqvsaXTTxyJrzj4WnHsgIwa5to=; b=aCKoSOhNcBXl5pKmAIrFVuNHFEGj+PGjgUVkJKx/EJSE6uIC/zUF1sMuA+qQ4UAVu3ZkfwVh1deTd7m72UOefzfixNNwxpV91SZnuZBwC5byICInysQ5jhBCWs632Z+6pw7ged6DLjDTla8tx3KvwrDywokl0RulPvxTeKdC6YY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1638543665996536.3792067384118; Fri, 3 Dec 2021 07:01:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470-5iRJG5rOPRSuA48e7AFlvQ-1; Fri, 03 Dec 2021 10:01:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74C121014503; Fri, 3 Dec 2021 15:00:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BE735F4E9; Fri, 3 Dec 2021 15:00:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A4A64BB7C; Fri, 3 Dec 2021 15:00:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B3Ew0nV029692 for ; Fri, 3 Dec 2021 09:58:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id B289B10016F4; Fri, 3 Dec 2021 14:58:00 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07D9F10016F5 for ; Fri, 3 Dec 2021 14:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543665; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ITx/BivkhRdHS4Yc2sqvsaXTTxyJrzj4WnHsgIwa5to=; b=Ch3YZIhuLTRGFOlfzbXXSrApekADqAxY8T8HlO+LmI1OMiwyX5wd+wa+GXdB0MJWSovhWJ CEiON7Yr1QQ+XOszBHqB+xGG7sbz3iD54ag9uDXQZixTLsa5uyuMBFPVA4TyaZJeYlPR3P cdipzEMgBtfxEWg5Rsf7Zz4padpnpEo= X-MC-Unique: 5iRJG5rOPRSuA48e7AFlvQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/16] qemuAgentIOProcessLine: refactor cleanup Date: Fri, 3 Dec 2021 15:57:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638543666728100001 Content-Type: text/plain; charset="utf-8" Refactor the control flow so we can remove the cleanup label. Signed-off-by: Peter Krempa --- src/qemu/qemu_agent.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index fc402e936f..c573e0fdf4 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -234,8 +234,7 @@ qemuAgentIOProcessLine(qemuAgent *agent, const char *line, qemuAgentMessage *msg) { - virJSONValue *obj =3D NULL; - int ret =3D -1; + g_autoptr(virJSONValue) obj =3D NULL; VIR_DEBUG("Line [%s]", line); @@ -247,19 +246,19 @@ qemuAgentIOProcessLine(qemuAgent *agent, return 0; } - goto cleanup; + return -1; } if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Parsed JSON reply '%s' isn't an object"), line); - goto cleanup; + return -1; } if (virJSONValueObjectHasKey(obj, "QMP") =3D=3D 1) { - ret =3D 0; + return 0; } else if (virJSONValueObjectHasKey(obj, "event") =3D=3D 1) { - ret =3D qemuAgentIOProcessEvent(agent, obj); + return qemuAgentIOProcessEvent(agent, obj); } else if (virJSONValueObjectHasKey(obj, "error") =3D=3D 1 || virJSONValueObjectHasKey(obj, "return") =3D=3D 1) { if (msg) { @@ -268,8 +267,7 @@ qemuAgentIOProcessLine(qemuAgent *agent, if (virJSONValueObjectGetNumberUlong(obj, "return", &id) <= 0) { VIR_DEBUG("Ignoring delayed reply on sync"); - ret =3D 0; - goto cleanup; + return 0; } VIR_DEBUG("Guest returned ID: %llu", id); @@ -277,8 +275,7 @@ qemuAgentIOProcessLine(qemuAgent *agent, if (msg->id !=3D id) { VIR_DEBUG("Guest agent returned ID: %llu instead of %l= lu", id, msg->id); - ret =3D 0; - goto cleanup; + return 0; } } msg->rxObject =3D g_steal_pointer(&obj); @@ -287,15 +284,13 @@ qemuAgentIOProcessLine(qemuAgent *agent, /* we are out of sync */ VIR_DEBUG("Ignoring delayed reply"); } - ret =3D 0; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown JSON reply '%s'"), line); + + return 0; } - cleanup: - virJSONValueFree(obj); - return ret; + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown JSON reply '%s'"), line); + return -1; } static int qemuAgentIOProcessData(qemuAgent *agent, --=20 2.31.1