From nobody Wed Feb 11 02:54:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1672997163; cv=none; d=zohomail.com; s=zohoarc; b=XbVjCj/64aoyQCNnh1aPECa0w3tvejMDgAQRnKNXZp58TGwoXJ70UaIWIeviR34ERWVk/Q+mgiU01o32mvb2loUcH33l20xc4Rx0+c9TotQJvQWrhaUo1szgUALNne9zKPcSs4awJY4kbv+TpvywvC/FpjCZWbdfLXcsxiE9k4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672997163; 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=eZJHPVmsdJ14lvLgdUOfaKOobT4ssP+6uVAyDVr2wlc=; b=FqFYcHPBsiDfkB+ThK8fyvORZ6wcongKPHUFT3AbQOqh0PzJdVUyXynGIxH97X073XIGwj4kDTlJ2A5M6q8/MXtvwdq0YhwzzOoaAcJhaRwW5PpgkM/mUDbsIz11fsMnQygmJh+VkFjZQdXl2GrkulisflqMNwQXPVAG63UslKM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672997163140824.8204709432289; Fri, 6 Jan 2023 01:26:03 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-8ult53k2O6OqnQ3Ii6GZ-A-1; Fri, 06 Jan 2023 04:25:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 026E31C0A5A3; Fri, 6 Jan 2023 09:25:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC00140EBF5; Fri, 6 Jan 2023 09:25:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 93CBB1946A40; Fri, 6 Jan 2023 09:25:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CD86E1946586 for ; Fri, 6 Jan 2023 09:24:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C2298492B07; Fri, 6 Jan 2023 09:24:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA2FD492B06 for ; Fri, 6 Jan 2023 09:24:58 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EBA729AA381 for ; Fri, 6 Jan 2023 09:24:58 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-JQFtx0MsOrm-qKoY6uC3cQ-1; Fri, 06 Jan 2023 04:24:56 -0500 Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NpHqc21MCzqTsK for ; Fri, 6 Jan 2023 17:20:12 +0800 (CST) Received: from localhost.localdomain (10.175.124.27) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 6 Jan 2023 17:24:53 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672997162; 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=eZJHPVmsdJ14lvLgdUOfaKOobT4ssP+6uVAyDVr2wlc=; b=LoMKmMClltKEjbezOra+LsDRqYg9/p8S9/sDtlF0T6Q2XXcCrcISSnW4V+6LnZxrMjmC/i SpiTVHRxvfHK2aMvzbG6PzPHdqZsW6DTLFvgNIpsPqj7wx1tsJUrme7FYxd4X93Gmw2XdX 9Akx75Z54PXD3HkENt1mOMqJcdPOl04= X-MC-Unique: 8ult53k2O6OqnQ3Ii6GZ-A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: JQFtx0MsOrm-qKoY6uC3cQ-1 From: Jiang Jiacheng To: Subject: [PATCH 2/9] interface: use g_autofree and remove unnecessary label Date: Fri, 6 Jan 2023 17:18:32 +0800 Message-ID: <20230106091839.1263372-3-jiangjiacheng@huawei.com> In-Reply-To: <20230106091839.1263372-1-jiangjiacheng@huawei.com> References: <20230106091839.1263372-1-jiangjiacheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yubihong@huawei.com, zhengchuan@huawei.com, linyilu@huawei.com, jiangjiacheng@huawei.com, xiexiangyou@huawei.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1672997164957100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiang Jiacheng --- src/interface/interface_backend_udev.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 979f187d87..54b43fb999 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -879,24 +879,23 @@ udevGetIfaceDefVlan(struct udev *udev G_GNUC_UNUSED, const char *name, virInterfaceDef *ifacedef) { - char *procpath =3D NULL; - char *buf =3D NULL; + g_autofree char *procpath =3D NULL; + g_autofree char *buf =3D NULL; char *vid_pos, *dev_pos; size_t vid_len, dev_len; const char *vid_prefix =3D "VID: "; const char *dev_prefix =3D "\nDevice: "; - int ret =3D -1; =20 procpath =3D g_strdup_printf("/proc/net/vlan/%s", name); =20 if (virFileReadAll(procpath, BUFSIZ, &buf) < 0) - goto cleanup; + return -1; =20 if ((vid_pos =3D strstr(buf, vid_prefix)) =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to find the VID for the VLAN device '%s'"= ), name); - goto cleanup; + return -1; } vid_pos +=3D strlen(vid_prefix); =20 @@ -905,14 +904,14 @@ udevGetIfaceDefVlan(struct udev *udev G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to find the VID for the VLAN device '%s'"= ), name); - goto cleanup; + return -1; } =20 if ((dev_pos =3D strstr(vid_pos + vid_len, dev_prefix)) =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to find the real device for the VLAN devi= ce '%s'"), name); - goto cleanup; + return -1; } dev_pos +=3D strlen(dev_prefix); =20 @@ -920,18 +919,13 @@ udevGetIfaceDefVlan(struct udev *udev G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to find the real device for the VLAN devi= ce '%s'"), name); - goto cleanup; + return -1; } =20 ifacedef->data.vlan.tag =3D g_strndup(vid_pos, vid_len); ifacedef->data.vlan.dev_name =3D g_strndup(dev_pos, dev_len); =20 - ret =3D 0; - - cleanup: - VIR_FREE(procpath); - VIR_FREE(buf); - return ret; + return 0; } =20 static virInterfaceDef * ATTRIBUTE_NONNULL(1) --=20 2.33.0