From nobody Mon Feb 9 11:07:19 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=1644482019; cv=none; d=zohomail.com; s=zohoarc; b=P9G8H8D2ZAkBy2o9f59HyDUsBVlncCIHDrgwe5gozdfcNmrnjGrSBQ2hBA3tJoqWAV/xj240QLO5a7iuybCyZxr4ilcDK6gBmqN06mzgFOQsDoIn5RFhjaM/cMUQw0DBYtTaoR3rzZZNabeyxfjZDxI2falIC3Pt9NflU3R5sBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644482019; 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=o6S45ddfm0GLO9QidjNoF2OOrVjBlrWu3WRN/KmjFGA=; b=AgLvregyog8ZkCOGqO4aavNp9WGjyMtNzsufDaOUbMf7D/CjZOUEOCx90hPQM3caQHPJ/qB+UaZFMHuSQ1JRK4OC2/0sJCmrZ/4aIIJZp4mAP9oOCQH+zC14uge2nzrR6Kq4jh/UmtCclinL8qsiYrDfn3ZZwpsUjObfeJ9qaXs= 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 1644482019164286.79492897826026; Thu, 10 Feb 2022 00:33:39 -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-214-yOc6rwwGMJa7CE2BwNMCoQ-1; Thu, 10 Feb 2022 03:33:36 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1FF98143EA; Thu, 10 Feb 2022 08:33:31 +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 BC7247315E; Thu, 10 Feb 2022 08:33:31 +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 8C2214A7C8; Thu, 10 Feb 2022 08:33:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21A8XQct003023 for ; Thu, 10 Feb 2022 03:33:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4785B2657D; Thu, 10 Feb 2022 08:33:26 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB50A26E7E for ; Thu, 10 Feb 2022 08:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644482018; 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=o6S45ddfm0GLO9QidjNoF2OOrVjBlrWu3WRN/KmjFGA=; b=IQ0fG9LL0lJa3CY52c59W37X7gcgCJEps8z7619UhYI8h3LU97jJYlyJdFlX/dP2zXSlXx ttTy7z6qLxC4uNo0dW0fwnpivBhFoXdCzC5ZFCljohosmTOLtHQtZGbLuaPLr0mtBlacS+ aYFCSAxaxuimk/orO+lS3pQwIpFaj4A= X-MC-Unique: yOc6rwwGMJa7CE2BwNMCoQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemuMonitorOpenUnix: Refactor cleanup Date: Thu, 10 Feb 2022 09:33:09 +0100 Message-Id: <6f42c1abf03ab4a752ee784065ffd2296e825e48.1644481928.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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: 1644482020909100001 Content-Type: text/plain; charset="utf-8" Use VIR_AUTOFREE for the temp socket so that the 'error:' label can be removed. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fcd39b80c6..04b5cce6fb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -233,7 +233,7 @@ qemuMonitorOpenUnix(const char *monitor, unsigned long long timeout) { struct sockaddr_un addr; - int monfd; + VIR_AUTOCLOSE monfd =3D -1; virTimeBackOffVar timebackoff; int ret =3D -1; @@ -248,12 +248,12 @@ qemuMonitorOpenUnix(const char *monitor, if (virStrcpyStatic(addr.sun_path, monitor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Monitor path %s too big for destination"), monit= or); - goto error; + return -1; } if (retry) { if (virTimeBackOffStart(&timebackoff, 1, timeout * 1000) < 0) - goto error; + return -1; while (virTimeBackOffWait(&timebackoff)) { ret =3D connect(monfd, (struct sockaddr *)&addr, sizeof(addr)); @@ -269,28 +269,27 @@ qemuMonitorOpenUnix(const char *monitor, virReportSystemError(errno, "%s", _("failed to connect to monitor socket")); - goto error; + return -1; } if (ret !=3D 0) { virReportSystemError(errno, "%s", _("monitor socket did not show up")); - goto error; + return -1; } } else { ret =3D connect(monfd, (struct sockaddr *) &addr, sizeof(addr)); if (ret < 0) { virReportSystemError(errno, "%s", _("failed to connect to monitor socket")); - goto error; + return -1; } } - return monfd; + ret =3D monfd; + monfd =3D -1; - error: - VIR_FORCE_CLOSE(monfd); - return -1; + return ret; } --=20 2.34.1