From nobody Sat Feb 7 05:57:17 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=1632344229; cv=none; d=zohomail.com; s=zohoarc; b=HWYopAP0YHImuF4cT9UQaczhUBjZs8GhxA8OHwtI0SnukY2hyWb2BGUQ9Q9wWg/68vjcoD+kZSEKxAcg5wPuSM3O3IUoaHXecsSXLUNvxrYKof8UOiLnQ7MVPTZvR/Qi4kX9vnVapA9ZgpsrQX6aAbc5Lj/4QMjSuxKCM9xUOQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632344229; h=Content-Type:Content-Transfer-Encoding:Cc: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=WRvIOKlqmHZV64Whv13K6NoWp05LratIK+MxJxk8S3g=; b=Uihclbffl9w19w/h9bdBKBNw4DUnQ9c2jC69HaqJnmyxxLzBPzPEAeb/mZUlz1/RxF9O7NILIEpDXdurN8sLaMz8OhlbtS0kMc11zutaUFqbclyCpBXVJUK4XkFfEzkzJ2OSMF8gidcp41dUkvoV0caODBeciXB9/UPFyXOvVtE= 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 1632344229850284.7098659969703; Wed, 22 Sep 2021 13:57:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-2ExIFIEXPMiZZNzxdVZOwQ-1; Wed, 22 Sep 2021 16:56:15 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15D291006AA6; Wed, 22 Sep 2021 20:56:10 +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 E20E619736; Wed, 22 Sep 2021 20:56:09 +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 AF4574EA3A; Wed, 22 Sep 2021 20:56:09 +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 18MKu2lQ007561 for ; Wed, 22 Sep 2021 16:56:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id B9DA219733; Wed, 22 Sep 2021 20:56:02 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CC5E1972D; Wed, 22 Sep 2021 20:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632344228; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WRvIOKlqmHZV64Whv13K6NoWp05LratIK+MxJxk8S3g=; b=Gye8KMAWrcTSPdGhgSLRXLQaX4gcgK+827f9/EwqHg48jM0jZMV1+YTsgRVuB08HywXHhR g3G+GVOlwYgEhIRB5FPiFApHwiggCZe0UdJpJQ0/AgFCO0MPng/d8BOZKU7Ckk/2yg3cV2 20zYwv+BBLvjme/wFFrTAYqMec69/7o= X-MC-Unique: 2ExIFIEXPMiZZNzxdVZOwQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] ch: use g_auto in virCHMonitorBuildNetJson Date: Wed, 22 Sep 2021 22:55:32 +0200 Message-Id: <2519ce06127d94e372ece602763378a89653cb72.1632344053.git.jtomko@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 Cc: william.douglas@intel.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.84 on 10.5.11.23 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632344230940100001 Signed-off-by: J=C3=A1n Tomko --- src/ch/ch_monitor.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index d268dc3c90..21f8cb6782 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -233,7 +233,7 @@ virCHMonitorBuildNetJson(virJSONValue *nets, virDomainN= etDef *netdef) { virDomainNetType netType =3D virDomainNetGetActualType(netdef); char macaddr[VIR_MAC_STRING_BUFLEN]; - virJSONValue *net; + g_autoptr(virJSONValue) net =3D NULL; =20 // check net type at first net =3D virJSONValueNewObject(); @@ -246,20 +246,20 @@ virCHMonitorBuildNetJson(virJSONValue *nets, virDomai= nNetDef *netdef) virSocketAddr netmask; g_autofree char *netmaskStr =3D NULL; if (!(addr =3D virSocketAddrFormat(&ip->address))) - goto cleanup; + return -1; if (virJSONValueObjectAppendString(net, "ip", addr) < 0) - goto cleanup; + return -1; =20 if (virSocketAddrPrefixToNetmask(ip->prefix, &netmask, AF_INET= ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to translate net prefix %d to net= mask"), ip->prefix); - goto cleanup; + return -1; } if (!(netmaskStr =3D virSocketAddrFormat(&netmask))) - goto cleanup; + return -1; if (virJSONValueObjectAppendString(net, "mask", netmaskStr) < = 0) - goto cleanup; + return -1; } else if (netdef->guestIP.nips > 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("ethernet type supports a single guest ip")); @@ -269,12 +269,12 @@ virCHMonitorBuildNetJson(virJSONValue *nets, virDomai= nNetDef *netdef) if ((virDomainChrType)netdef->data.vhostuser->type !=3D VIR_DOMAIN= _CHR_TYPE_UNIX) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vhost_user type support UNIX socket in this = CH")); - goto cleanup; + return -1; } else { if (virJSONValueObjectAppendString(net, "vhost_socket", netdef= ->data.vhostuser->data.nix.path) < 0) - goto cleanup; + return -1; if (virJSONValueObjectAppendBoolean(net, "vhost_user", true) <= 0) - goto cleanup; + return -1; } break; case VIR_DOMAIN_NET_TYPE_BRIDGE: @@ -291,26 +291,26 @@ virCHMonitorBuildNetJson(virJSONValue *nets, virDomai= nNetDef *netdef) case VIR_DOMAIN_NET_TYPE_LAST: default: virReportEnumRangeError(virDomainNetType, netType); - goto cleanup; + return -1; } =20 if (netdef->ifname !=3D NULL) { if (virJSONValueObjectAppendString(net, "tap", netdef->ifname) < 0) - goto cleanup; + return -1; } if (virJSONValueObjectAppendString(net, "mac", virMacAddrFormat(&netde= f->mac, macaddr)) < 0) - goto cleanup; + return -1; =20 =20 if (netdef->virtio !=3D NULL) { if (netdef->virtio->iommu =3D=3D VIR_TRISTATE_SWITCH_ON) { if (virJSONValueObjectAppendBoolean(net, "iommu", true) < 0) - goto cleanup; + return -1; } } if (netdef->driver.virtio.queues) { if (virJSONValueObjectAppendNumberInt(net, "num_queues", netdef->d= river.virtio.queues) < 0) - goto cleanup; + return -1; } =20 if (netdef->driver.virtio.rx_queue_size || netdef->driver.virtio.tx_qu= eue_size) { @@ -319,20 +319,16 @@ virCHMonitorBuildNetJson(virJSONValue *nets, virDomai= nNetDef *netdef) _("virtio rx_queue_size option %d is not same with tx_queue= _size %d"), netdef->driver.virtio.rx_queue_size, netdef->driver.virtio.tx_queue_size); - goto cleanup; + return -1; } if (virJSONValueObjectAppendNumberInt(net, "queue_size", netdef->d= river.virtio.rx_queue_size) < 0) - goto cleanup; + return -1; } =20 if (virJSONValueArrayAppend(nets, &net) < 0) - goto cleanup; + return -1; =20 return 0; - - cleanup: - virJSONValueFree(net); - return -1; } =20 static int --=20 2.31.1