From nobody Mon Apr 29 01:03:04 2024 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=1642438996; cv=none; d=zohomail.com; s=zohoarc; b=le4eAQwGm46RTgQEdzL5QwRx/fGQZ/L7z2ZU9kh/wR5l/zaPaM7uwQQ7M5jsLnEcSBiF347wkz/E7Uo5K1J1//R2W9JTVujCpmQScUawUMi7AKhKB2471V4WIwNF+4b94Ds3eekNJBt1lIJBsV5P3BGfcSBCC4+d62zj6RbbFBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642438996; 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=qEIPsLMBwhAc9CHZpWUnyowHpBRBbBNXbmghvbARZN0=; b=Ira5SsDcX/T16y1L9zG4519KpeqjVMob6qP71SOj1wxSp0sASXqENOtFERvzo6iqC8QtbVTplGUf5uQ+3BWWBBcHAoGoIjg10xXgEBerg5eCliwZuXoLPg/nG9kfgCeMthj5lmHZb4SRLoWShicW7/XJq/7GGdWsVQ0S1jEOu+I= 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 1642438996816507.6426173994495; Mon, 17 Jan 2022 09:03:16 -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-614-SvEi1cC4OB6WKAw2oxR7Pw-1; Mon, 17 Jan 2022 12:03:13 -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 12BBD39393; Mon, 17 Jan 2022 17:03:08 +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 DBCE35E493; Mon, 17 Jan 2022 17:03:07 +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 402DF4A706; Mon, 17 Jan 2022 17:03:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HH2tcb012485 for ; Mon, 17 Jan 2022 12:02:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7D5DF71DE3; Mon, 17 Jan 2022 17:02:55 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0616671DE2 for ; Mon, 17 Jan 2022 17:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642438995; 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=qEIPsLMBwhAc9CHZpWUnyowHpBRBbBNXbmghvbARZN0=; b=NS/XGYhLCSkoaNwxTIwtpuOSJAElUwaPXRk8c5TqtNH9VfNhClBY0DPq2UOlw2gZziNVmN KAtVk3kEylJZjH1Uar3TTa9ytOFfLN7/rQ8Iu5xvln2XtQQIsModCONxWA17bje17qhaol F7UFnv1JwrXGQhoLp3se6RCENGH3Yu8= X-MC-Unique: SvEi1cC4OB6WKAw2oxR7Pw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/6] util: midonet: use g_auto for virCommand Date: Mon, 17 Jan 2022 18:02:28 +0100 Message-Id: <59166812338df64bcb0f0cc109a746cfced5fa28.1642438847.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642438997871100003 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevmidonet.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/util/virnetdevmidonet.c b/src/util/virnetdevmidonet.c index 9061f1516f..72b2fd4467 100644 --- a/src/util/virnetdevmidonet.c +++ b/src/util/virnetdevmidonet.c @@ -39,8 +39,7 @@ int virNetDevMidonetBindPort(const char *ifname, const virNetDevVPortProfile *virtualport) { - int ret =3D -1; - virCommand *cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; char virtportuuid[VIR_UUID_STRING_BUFLEN]; =20 virUUIDFormat(virtualport->interfaceID, virtportuuid); @@ -53,13 +52,10 @@ virNetDevMidonetBindPort(const char *ifname, virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to bind port %s to the virtual port %s"), ifname, virtportuuid); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - virCommandFree(cmd); - return ret; + return 0; } =20 /** @@ -73,8 +69,7 @@ virNetDevMidonetBindPort(const char *ifname, int virNetDevMidonetUnbindPort(const virNetDevVPortProfile *virtualport) { - int ret =3D -1; - virCommand *cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; char virtportuuid[VIR_UUID_STRING_BUFLEN]; =20 virUUIDFormat(virtualport->interfaceID, virtportuuid); @@ -86,11 +81,8 @@ virNetDevMidonetUnbindPort(const virNetDevVPortProfile *= virtualport) virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to unbind the virtual port %s from Midone= t"), virtportuuid); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - virCommandFree(cmd); - return ret; + return 0; } --=20 2.31.1 From nobody Mon Apr 29 01:03:04 2024 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=1642439054; cv=none; d=zohomail.com; s=zohoarc; b=jUP9Z/OaJScpRC/qgasy+d/1zj1ULRkzjV/yOjR5tMuyIOgSMN1RSrXKhlhLBJLIJy3iGDQdC4VBvFFuSwH8gOXq0Kj9IGPahjzAsBlbR3oIoh6w6AoG5+OOo95kg4qKkKQvL/RfbDhuHA9GWx4pJta5pXs8kYmfTL5TssaIswU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642439054; 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=sFuV4IGL4DSH4Mik8dtzCptzvAQhE7/ntyeCeUwSYjo=; b=UkyLV3PxBivQdeQUE4187wxhyIE+Q4rzavc7XkTo7UkodCIoIdan7YPFScu+PszILHB/kw0wU+Gz96QBnbqWMCTSArzxl+pRTdVgLef5XCXo025ECJc0DM05jLF+sOU5nQGSEGAzj1b9wEAyKfyMIaP2r7GFc/4DKFK1MfrLyBM= 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 1642439054923841.3160212902119; Mon, 17 Jan 2022 09:04:14 -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-332-lciCryeDMoemA_1wTl0caA-1; Mon, 17 Jan 2022 12:04:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D1491853020; Mon, 17 Jan 2022 17:04:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F15937A3FA; Mon, 17 Jan 2022 17:04:06 +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 6AF6C1802E2B; Mon, 17 Jan 2022 17:04:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HH2uYj012497 for ; Mon, 17 Jan 2022 12:02:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4BFF471DE3; Mon, 17 Jan 2022 17:02:56 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA05F71DE2 for ; Mon, 17 Jan 2022 17:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642439053; 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=sFuV4IGL4DSH4Mik8dtzCptzvAQhE7/ntyeCeUwSYjo=; b=iCoNqv4pXGF+wooxWdiSWDhB5LrO/ifrqnakrqB3PCQ1hXC/jojNH27LGjlpfrd3ePRysl BJxQ1M4gL/aqicgw9Dx3XOx4wGu2QByi4zTpqlaGRExXyXCqI5WPLaT6Bpa2AhmWiKjU7W /in7SFArDJDu/bonnNcNcfJvfuz7vug= X-MC-Unique: lciCryeDMoemA_1wTl0caA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/6] util: virNetDevBandwidthUpdateRate: refactor Date: Mon, 17 Jan 2022 18:02:29 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.14 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: 1642439055920100003 Use automatic cleanup and remove the 'ret' variable in favor of direct returns. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevbandwidth.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index 75fc5607ad..083b860059 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -685,11 +685,10 @@ virNetDevBandwidthUpdateRate(const char *ifname, virNetDevBandwidth *bandwidth, unsigned long long new_rate) { - int ret =3D -1; - virCommand *cmd =3D NULL; - char *class_id =3D NULL; - char *rate =3D NULL; - char *ceil =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *class_id =3D NULL; + g_autofree char *rate =3D NULL; + g_autofree char *ceil =3D NULL; =20 class_id =3D g_strdup_printf("1:%x", id); rate =3D g_strdup_printf("%llukbps", new_rate); @@ -703,17 +702,7 @@ virNetDevBandwidthUpdateRate(const char *ifname, "ceil", ceil, NULL); virNetDevBandwidthCmdAddOptimalQuantum(cmd, bandwidth->in); =20 - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; - - ret =3D 0; - - cleanup: - virCommandFree(cmd); - VIR_FREE(class_id); - VIR_FREE(rate); - VIR_FREE(ceil); - return ret; + return virCommandRun(cmd, NULL); } =20 /** --=20 2.31.1 From nobody Mon Apr 29 01:03:04 2024 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=1642439001; cv=none; d=zohomail.com; s=zohoarc; b=Wyxj6ukB0rXr9vFkGbsbfTiMS73YgZ4JnBV0ELC5ICdx/blafIvrgR9u+D43En5sjHEKCJgPaZyBEf5rMtMJympNKk6hbhOCmkLSsF2JUElU6DDO8Dtz9csHUQPrJy2EuHKrVrq5LlC3deaEvmEiS+MjOxwUUhSYvnpsMJYmPHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642439001; 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=hR4hWSB1uhIC3pK84cLU71yL4UCCse3CKkArrgCQMIg=; b=DpO3aFh16oKB6Zx5bwcud1a80qKfa89JRZnC7gVUPPU3Ne+4Rkbi8t8XiaxIqxNMki98ykzWhqMweDjzHtVGDR6rvABc1wWsfOr2aMl8v7XU1MfQRyYasJ8oXzSBv1351VeCMlb0/J4KprHqgdOZfw0T9OtdJM9y1TnqJ/5czx8= 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 1642439001695857.6008243313024; Mon, 17 Jan 2022 09:03:21 -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-618-UsNakJDmMu-xBYbJ3zVEwA-1; Mon, 17 Jan 2022 12:03:17 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FB661083F60; Mon, 17 Jan 2022 17:03:12 +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 1F9B378C31; Mon, 17 Jan 2022 17:03:12 +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 D78D74A707; Mon, 17 Jan 2022 17:03:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HH2vhc012502 for ; Mon, 17 Jan 2022 12:02:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A04A71DE3; Mon, 17 Jan 2022 17:02:57 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9842171DE2 for ; Mon, 17 Jan 2022 17:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642439000; 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=hR4hWSB1uhIC3pK84cLU71yL4UCCse3CKkArrgCQMIg=; b=hrrDLNGAFt3dCR1ZNUVE4AGbKfxbjq//kFWK4mF9vyPrquO/MXfj+4f7mDGMvyrVnvsHYZ w255PSd4rn2nTGZxcJOVo/r4vl3J5CQUn+KAZmmFoQx40h4HJo0+KSP2WbyrK6lRSP+oIk +n5VDaH3GBi/yfiANk+VcEUY23zjWQg= X-MC-Unique: UsNakJDmMu-xBYbJ3zVEwA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/6] util: virNetDevBandwidthManipulateFilter: use g_auto Date: Mon, 17 Jan 2022 18:02:30 +0100 Message-Id: <5562d9e6fb5775fa64a33a4337bd60d4566edbe7.1642438847.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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: 1642439003441100001 Reduce the scope of the variable to avoid renaming it. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevbandwidth.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index 083b860059..fe354696f2 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -105,8 +105,7 @@ virNetDevBandwidthManipulateFilter(const char *ifname, bool create_new) { int ret =3D -1; - char *filter_id =3D NULL; - virCommand *cmd =3D NULL; + g_autofree char *filter_id =3D NULL; unsigned char ifmac[VIR_MAC_BUFLEN]; char *mac[2] =3D {NULL, NULL}; =20 @@ -120,9 +119,9 @@ virNetDevBandwidthManipulateFilter(const char *ifname, filter_id =3D g_strdup_printf("800::%u", id); =20 if (remove_old) { + g_autoptr(virCommand) cmd =3D virCommandNew(TC); int cmd_ret =3D 0; =20 - cmd =3D virCommandNew(TC); virCommandAddArgList(cmd, "filter", "del", "dev", ifname, "prio", "2", "handle", filter_id, "u32", NUL= L); =20 @@ -132,14 +131,13 @@ virNetDevBandwidthManipulateFilter(const char *ifname, } =20 if (create_new) { + g_autoptr(virCommand) cmd =3D virCommandNew(TC); virMacAddrGetRaw(ifmac_ptr, ifmac); =20 mac[0] =3D g_strdup_printf("0x%02x%02x%02x%02x", ifmac[2], ifmac[3], ifmac[4], ifmac[5]); mac[1] =3D g_strdup_printf("0x%02x%02x", ifmac[0], ifmac[1]); =20 - virCommandFree(cmd); - cmd =3D virCommandNew(TC); /* Okay, this not nice. But since libvirt does not necessarily tra= ck * interface IP address(es), and tc fw filter simply refuse to use * ebtables marks, we need to use u32 selector to match MAC addres= s. @@ -160,8 +158,6 @@ virNetDevBandwidthManipulateFilter(const char *ifname, cleanup: VIR_FREE(mac[1]); VIR_FREE(mac[0]); - VIR_FREE(filter_id); - virCommandFree(cmd); return ret; } =20 --=20 2.31.1 From nobody Mon Apr 29 01:03:04 2024 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=1642439004; cv=none; d=zohomail.com; s=zohoarc; b=drIhEulA0ydUbyRiW8lVhJiLO54Y8l1WyRKmEhDM0hk0QpK4AFj6E5SgTzDAc7KR7aTMZOuUeS4fDm6YaQaThSj58nBYl4i+x4ggM1PY23M+6vPY6EzeME6l5nuhIur+eT6W153JPdcE8RUu+PUMEGCPqUBkn4Hk6fc7mw+Axpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642439004; 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=VJJ3y/r5bWxREr3+vTkabGge7HQ+1mKdqk2UcdT+l1o=; b=NGW0HLthhB0GMceVgUnqVvajVuxB8BaPi2xt5ugYTZZVje8x7UW9VCzQDJ2HU6DMRtobFkLr9hPsrzI4YzrdqmDbhgE9+B+BySSyVj988gv/nPcGXnXxExpy1oaYZ5faXOr3P+KgwoBJmNzZ3dEuIQLBV/sTT2sSh5QsxhjgMNk= 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 1642439004196510.2553753401579; Mon, 17 Jan 2022 09:03:24 -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-182-e7IcGSkmOPawmLtZmqhzQg-1; Mon, 17 Jan 2022 12:03:21 -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 24C9C84BA57; Mon, 17 Jan 2022 17:03:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3C205E4A6; Mon, 17 Jan 2022 17:03:15 +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 AF7DC1809CB9; Mon, 17 Jan 2022 17:03:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HH2vAs012513 for ; Mon, 17 Jan 2022 12:02:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id DC83D5E4A6; Mon, 17 Jan 2022 17:02:57 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6655B71DE6 for ; Mon, 17 Jan 2022 17:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642439003; 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=VJJ3y/r5bWxREr3+vTkabGge7HQ+1mKdqk2UcdT+l1o=; b=GWx3r5d6mVa99/IR7bsGjpKpyOG7VVy9oZrE8cbfHRWbdiTgISj4AmTpjE+cW4qvF1Ekx2 P87y4eSdUspk31N/zbHeQJUcz6N1JA60N+D3h4hRESUXKXfa/R4wK834sPC0lQT1EIe0i8 IXXIGJzDCTAm4P8FKE/lALXGzUSKgvo= X-MC-Unique: e7IcGSkmOPawmLtZmqhzQg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/6] util: virNetDevBandwidthClear: use g_auto Date: Mon, 17 Jan 2022 18:02:31 +0100 Message-Id: <221b257fb3d6d75386d62887ca3c73bf8452779c.1642438847.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642439005989100001 Separate the two uses of 'cmd' to avoid mixing manual and automatic cleanup. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevbandwidth.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index fe354696f2..cb9a22a369 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -416,27 +416,24 @@ virNetDevBandwidthClear(const char *ifname) { int ret =3D 0; int dummy; /* for ignoring the exit status */ - virCommand *cmd =3D NULL; + g_autoptr(virCommand) rootcmd =3D NULL; + g_autoptr(virCommand) ingresscmd =3D NULL; =20 if (!ifname) return 0; =20 - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL); + rootcmd =3D virCommandNew(TC); + virCommandAddArgList(rootcmd, "qdisc", "del", "dev", ifname, "root", N= ULL); =20 - if (virCommandRun(cmd, &dummy) < 0) + if (virCommandRun(rootcmd, &dummy) < 0) ret =3D -1; =20 - virCommandFree(cmd); + ingresscmd =3D virCommandNew(TC); + virCommandAddArgList(ingresscmd, "qdisc", "del", "dev", ifname, "ingr= ess", NULL); =20 - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "ingress", N= ULL); - - if (virCommandRun(cmd, &dummy) < 0) + if (virCommandRun(ingresscmd, &dummy) < 0) ret =3D -1; =20 - virCommandFree(cmd); - return ret; } =20 --=20 2.31.1 From nobody Mon Apr 29 01:03:04 2024 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=1642439008; cv=none; d=zohomail.com; s=zohoarc; b=NX1KzE+i5l1HzfcO//6SmZF47NzE4N7eYR+cY3pOYY85wKpGK1g6kf4buOIiF7CJ/saIIE1ZqJSrQopXzJ8UW59Hv0Ob53bk6H0qF3R2WQwtyK/+cdrMSacBAt5snCEf0JByKhSRiU8zQtiLxxM+sUf+K5gQizM0otokSHZDGp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642439008; 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=BAWNWa4vIMC6+8SkxX6Ml87fYDK6gTZhUqCV+aUmfEM=; b=hBfwp4SSSQe+W1czU9uf8MQ9PwpgT77yBLxFFCKUlmvonSuCWcsbEwluc/IdUSGSfTd++bmmc2EknseMQgfj09KCx3SfEhvoIQVBzr1F2aZwaR0YXdD4FqRDBgaBfcrWzitTX4Lx0YQ7X7fFcAfOhfjw1qKgV2mPjKk8CR/ejFI= 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 164243900828432.63683435665905; Mon, 17 Jan 2022 09:03:28 -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-550-O-eSzH6QNKOxrgVBfooXsg-1; Mon, 17 Jan 2022 12:03:25 -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 89384101873A; Mon, 17 Jan 2022 17:03:19 +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 2BF055B95A; Mon, 17 Jan 2022 17:03:19 +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 E5D804A707; Mon, 17 Jan 2022 17:03:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HH2wJ2012524 for ; Mon, 17 Jan 2022 12:02:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB9D8694C1; Mon, 17 Jan 2022 17:02:58 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34CC05E4A6 for ; Mon, 17 Jan 2022 17:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642439007; 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=BAWNWa4vIMC6+8SkxX6Ml87fYDK6gTZhUqCV+aUmfEM=; b=djxe7FzTf3kxiJ5inwrHR6725te/QPBsLNdJEglLSionqDPQSyVANFUq8NvemyqhrJtRPC GaHxGPtb8/sul47z/CSi41GH0VFUB27sxaX3cAZToDDv4HJxVa4rY/Th32sSsvyG4GAalj Wz230HAsza7SCsCP5XN/8ywByQfKfdw= X-MC-Unique: O-eSzH6QNKOxrgVBfooXsg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/6] util: refactor virNetDevBandwidthPlug Date: Mon, 17 Jan 2022 18:02:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642439009689100005 Use g_auto, split the double use of 'cmd' variable and remove useless ret variable. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevbandwidth.c | 43 ++++++++++++++--------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index cb9a22a369..7f394926ef 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -538,12 +538,12 @@ virNetDevBandwidthPlug(const char *brname, virNetDevBandwidth *bandwidth, unsigned int id) { - int ret =3D -1; - virCommand *cmd =3D NULL; - char *class_id =3D NULL; - char *qdisc_id =3D NULL; - char *floor =3D NULL; - char *ceil =3D NULL; + g_autoptr(virCommand) cmd1 =3D NULL; + g_autoptr(virCommand) cmd2 =3D NULL; + g_autofree char *class_id =3D NULL; + g_autofree char *qdisc_id =3D NULL; + g_autofree char *floor =3D NULL; + g_autofree char *ceil =3D NULL; char ifmacStr[VIR_MAC_STRING_BUFLEN]; =20 if (id <=3D 2) { @@ -568,37 +568,28 @@ virNetDevBandwidthPlug(const char *brname, net_bandwidth->in->peak : net_bandwidth->in->average); =20 - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "class", "add", "dev", brname, "parent", "1:= 1", + cmd1 =3D virCommandNew(TC); + virCommandAddArgList(cmd1, "class", "add", "dev", brname, "parent", "1= :1", "classid", class_id, "htb", "rate", floor, "ceil", ceil, NULL); - virNetDevBandwidthCmdAddOptimalQuantum(cmd, bandwidth->in); + virNetDevBandwidthCmdAddOptimalQuantum(cmd1, bandwidth->in); =20 - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + if (virCommandRun(cmd1, NULL) < 0) + return -1; =20 - virCommandFree(cmd); - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "qdisc", "add", "dev", brname, "parent", + cmd2 =3D virCommandNew(TC); + virCommandAddArgList(cmd2, "qdisc", "add", "dev", brname, "parent", class_id, "handle", qdisc_id, "sfq", "perturb", "10", NULL); =20 - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + if (virCommandRun(cmd2, NULL) < 0) + return -1; =20 if (virNetDevBandwidthManipulateFilter(brname, ifmac_ptr, id, class_id, false, true) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - VIR_FREE(ceil); - VIR_FREE(floor); - VIR_FREE(qdisc_id); - VIR_FREE(class_id); - virCommandFree(cmd); - return ret; + return 0; } =20 /* --=20 2.31.1 From nobody Mon Apr 29 01:03:04 2024 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=1642439045; cv=none; d=zohomail.com; s=zohoarc; b=hMjIWIgcwIEC1pPPAS4VRzkBFQmbRDKoz9/+Yc1lT86RY/YIN1+ayFh+KvMDgVsYQoYwRh46Gz4/u+PyySIFZEc0E7zX0dBHAQoitNmt8ijpNfBKffnAXuQSPcyzPoIDtCl93oet80iWApXlB80HtLfMKOPqX8edjZvF0AJ6YTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642439045; 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=UcrKK47A0ZeppzJDTcb7h+M4pxfNKBLlV6sGg/BDPwU=; b=Eg0Iz2Xauex05rRralM0BmTLCGenrvIL8PWvKB+OhJzJWzkpH3tx5AX5aYnlTWTPAuVuveDBRpeuEuNvOatoS0V4QsK8sJK3TNkASk7dMc8//6qQ1+w84ii7syUP717o9W3XLtwfG3OEjCIw2MNipn1xffvEZqaGUWtd7K6yF04= 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 1642439045537984.528753004718; Mon, 17 Jan 2022 09:04: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-553-2cLW4LOWMYOTWXe134aWFA-1; Mon, 17 Jan 2022 12:03:29 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 258E61083F61; Mon, 17 Jan 2022 17:03:22 +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 02DE0798CA; Mon, 17 Jan 2022 17:03:22 +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 C3DF44A70A; Mon, 17 Jan 2022 17:03:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HH2xHK012530 for ; Mon, 17 Jan 2022 12:02:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7BF465E4A6; Mon, 17 Jan 2022 17:02:59 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 041EC71DE2 for ; Mon, 17 Jan 2022 17:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642439044; 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=UcrKK47A0ZeppzJDTcb7h+M4pxfNKBLlV6sGg/BDPwU=; b=S4xg1dTqeZ4d913MsiTHmFt0/yIxEVyBYmUKomMxCZKdrB4NGHF32qi9Es5DtgaE2w92HB y1O+1a8QuOXAZiejXpkhGAFk1qVI6MOFA5CkJ9p0w0gIjgXN1Uxuu7cw4AtAnBsjgKys64 zL73/dvT5K5P1C6ToyiCUa3TmJSIZfM= X-MC-Unique: 2cLW4LOWMYOTWXe134aWFA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/6] util: refactor virNetDevBandwidthUnplug Date: Mon, 17 Jan 2022 18:02:33 +0100 Message-Id: <071abe51c7f004645dabf82715a82c4063856293.1642438847.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.14 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: 1642439046619100001 Remove pointless 'ret', cmd variable reuse and use g_auto. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetdevbandwidth.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index 7f394926ef..2895be8d27 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -605,11 +605,11 @@ int virNetDevBandwidthUnplug(const char *brname, unsigned int id) { - int ret =3D -1; int cmd_ret =3D 0; - virCommand *cmd =3D NULL; - char *class_id =3D NULL; - char *qdisc_id =3D NULL; + g_autoptr(virCommand) cmd1 =3D NULL; + g_autoptr(virCommand) cmd2 =3D NULL; + g_autofree char *class_id =3D NULL; + g_autofree char *qdisc_id =3D NULL; =20 if (id <=3D 2) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid class ID %d"), i= d); @@ -619,34 +619,27 @@ virNetDevBandwidthUnplug(const char *brname, class_id =3D g_strdup_printf("1:%x", id); qdisc_id =3D g_strdup_printf("%x:", id); =20 - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "qdisc", "del", "dev", brname, + cmd1 =3D virCommandNew(TC); + virCommandAddArgList(cmd1, "qdisc", "del", "dev", brname, "handle", qdisc_id, NULL); =20 /* Don't threat tc errors as fatal, but * try to remove as much as possible */ - if (virCommandRun(cmd, &cmd_ret) < 0) - goto cleanup; + if (virCommandRun(cmd1, &cmd_ret) < 0) + return -1; =20 if (virNetDevBandwidthManipulateFilter(brname, NULL, id, NULL, true, false) < 0) - goto cleanup; + return -1; =20 - virCommandFree(cmd); - cmd =3D virCommandNew(TC); - virCommandAddArgList(cmd, "class", "del", "dev", brname, + cmd2 =3D virCommandNew(TC); + virCommandAddArgList(cmd2, "class", "del", "dev", brname, "classid", class_id, NULL); =20 - if (virCommandRun(cmd, &cmd_ret) < 0) - goto cleanup; + if (virCommandRun(cmd2, &cmd_ret) < 0) + return -1; =20 - ret =3D 0; - - cleanup: - VIR_FREE(qdisc_id); - VIR_FREE(class_id); - virCommandFree(cmd); - return ret; + return 0; } =20 /** --=20 2.31.1