From nobody Mon Feb 9 09:15:38 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=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 --- 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