From nobody Mon Feb 9 03:30:00 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=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 --- 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