From nobody Sat May 4 23:49:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614085526; cv=none; d=zohomail.com; s=zohoarc; b=Yvnlqp5yETVmbwttvpNuHDUeR3XJ9FwqVTvsXX3VkIpf7u/+XjR39xIG7PXYT8kRBOnMkA7x/IyzUr4STmLRs9qucAWIihI9cl+bs77NbX/jMzjRSPfqiv30tS+0lAjJApNFTxsAAEzx4WeoDvpbYCZv2ZraKNHXwd/u3qcPl/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614085526; 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=XRsY/Vu2W+pmc1fQ/klSGNNodZXrDXe8qJ9DBvFY2Mw=; b=gNno47MbVWJROEFxRNVG48/CV0xlXyjcSejYn2aBFkMtEA3zG/SxaYSPtg8/9fHPFut+IV2UeNvo5HScjFUVO7zvDUWXrab2abvZKXUeNNc1rxcM+lQBS7CSWhM2TXS09KpUfUY8ac0Ebbk+UGIkDOJk8BtN/62SNxylxVBlvrc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614085525982736.5543475037421; Tue, 23 Feb 2021 05:05:25 -0800 (PST) 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-160-iWJiBMvXOZKI1Y0pq4JXaQ-1; Tue, 23 Feb 2021 08:05:22 -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 5C126814303; Tue, 23 Feb 2021 13:05:17 +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 3663D5D9D7; Tue, 23 Feb 2021 13:05:17 +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 EE47D18095CC; Tue, 23 Feb 2021 13:05:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11ND56HH010209 for ; Tue, 23 Feb 2021 08:05:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4256D60C47; Tue, 23 Feb 2021 13:05:06 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D23E60C04 for ; Tue, 23 Feb 2021 13:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614085524; 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=XRsY/Vu2W+pmc1fQ/klSGNNodZXrDXe8qJ9DBvFY2Mw=; b=CWKVM6AJXYtdNJaLh6G0qrLGRZypwx0YN9BCY3zzR6Ur/T4TYnwUYPrO6PlNYXbPbs+Tk2 /b0hguvu5OX7B1beqXuzKglWHxY25HhfyzY/gGwzDC614RHvVexvLhjfv2+EiIMIscWUWx 4BXgAYw/yL1NyuUiwbrKeC9nLHv7aCk= X-MC-Unique: iWJiBMvXOZKI1Y0pq4JXaQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 1/4] vsh-table: Use g_autofree where possible Date: Tue, 23 Feb 2021 14:04:45 +0100 Message-Id: <9ab6f7a4b698f5b1cf41eeab032c8bf6da31a821.1614085265.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In: vshTableRowNew(), vshTablePrint(), vshTablePrintToStdout(). Signed-off-by: Kristina Hanicova --- tools/vsh-table.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tools/vsh-table.c b/tools/vsh-table.c index d09cc9e14e..2e10abfc90 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -98,14 +98,12 @@ vshTableRowNew(const char *arg, va_list ap) row =3D g_new0(vshTableRow, 1); =20 while (arg) { - char *tmp =3D NULL; + g_autofree char *tmp =3D NULL; =20 tmp =3D g_strdup(arg); =20 - if (VIR_APPEND_ELEMENT(row->cells, row->ncells, tmp) < 0) { - VIR_FREE(tmp); + if (VIR_APPEND_ELEMENT(row->cells, row->ncells, tmp) < 0) goto error; - } =20 arg =3D va_arg(ap, const char *); } @@ -361,8 +359,8 @@ vshTablePrint(vshTablePtr table, bool header) { size_t i; size_t j; - size_t *maxwidths; - size_t **widths; + g_autofree size_t *maxwidths =3D NULL; + g_autofree size_t **widths =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *ret =3D NULL; =20 @@ -395,10 +393,8 @@ vshTablePrint(vshTablePtr table, bool header) ret =3D virBufferContentAndReset(&buf); =20 cleanup: - VIR_FREE(maxwidths); for (i =3D 0; i < table->nrows; i++) VIR_FREE(widths[i]); - VIR_FREE(widths); return ret; } =20 @@ -416,15 +412,13 @@ void vshTablePrintToStdout(vshTablePtr table, vshControl *ctl) { bool header; - char *out; + g_autofree char *out =3D NULL; =20 header =3D ctl ? !ctl->quiet : true; =20 out =3D vshTablePrintToString(table, header); if (out) vshPrint(ctl, "%s", out); - - VIR_FREE(out); } =20 =20 --=20 2.29.2 From nobody Sat May 4 23:49:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1614085529; cv=none; d=zohomail.com; s=zohoarc; b=CKJf8609gQMsnNxGXwAO8M+7PqzkgmbM9hnJHcir9tRJLNouP4V7xsFxmJNpFT8n7cGeleU/K4aVP/xZUIlH79385nRNDq6p4/JnELktDwpi/wlHgdQt7rR5yuVMAe2nSudUte/gQBDnurABXDksSKDjXTY6CYvfmktUoMda+Eg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614085529; 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=Z9SzVrt7cHaLv1h8dY2lU8AYRwrMjPbV57Kes51OtJc=; b=diExT2Zfpbftalf/ZMjrU+z/P72Adx99Iice+Az9HBjBFKhjiFNzq3TYDq1rLxNa7iROtWbK3CO+ppdBbZWgAUud/ATEaH5s8Nq1oR1U63UGEx5yO8GU2TnA7jEdnzU9vvQrn/t6GEJFEPL+si6uaZMV6BVfcla5Ii+UQXq4dqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1614085529508658.0310944774498; Tue, 23 Feb 2021 05:05:29 -0800 (PST) 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-397-6AapNo39PAyXap9LgigEOA-1; Tue, 23 Feb 2021 08:05:26 -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 9C2AA1936B78; Tue, 23 Feb 2021 13:05:20 +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 6D8E660C04; Tue, 23 Feb 2021 13:05:20 +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 2920C18095CD; Tue, 23 Feb 2021 13:05:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11ND58ha010219 for ; Tue, 23 Feb 2021 08:05:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id E3E5A60C47; Tue, 23 Feb 2021 13:05:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B0F760C04 for ; Tue, 23 Feb 2021 13:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614085528; 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=Z9SzVrt7cHaLv1h8dY2lU8AYRwrMjPbV57Kes51OtJc=; b=TL1oRmo1zTaSdxAfWdXIRvMoBQwXd5ih3kckeUJbDD0nDMQjINoNh4IwCgH3d1kbW1PkKo 0xKE89fx+sbQisHtFpISdj1SDxkpiWKv5MQDMAX9dybt7pkTM9eGy9aZB0CYN3/MSgrpa4 ZMD6yekhI0gCHY5BsR+N1l1pRtA3izU= X-MC-Unique: 6AapNo39PAyXap9LgigEOA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/4] netdev_bandwidth_conf: Use g_autofree where possible Date: Tue, 23 Feb 2021 14:04:46 +0100 Message-Id: <55dc48bfa71ed3624996c59bd02926ecbacb6270.1614085265.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/conf/netdev_bandwidth_conf.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 4fb7aa4e3d..1ff3785677 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -29,10 +29,10 @@ static int virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rat= e) { int ret =3D -1; - char *average =3D NULL; - char *peak =3D NULL; - char *burst =3D NULL; - char *floor =3D NULL; + g_autofree char *average =3D NULL; + g_autofree char *peak =3D NULL; + g_autofree char *burst =3D NULL; + g_autofree char *floor =3D NULL; =20 if (!node || !rate) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -88,11 +88,6 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBa= ndwidthRatePtr rate) ret =3D 0; =20 cleanup: - VIR_FREE(average); - VIR_FREE(peak); - VIR_FREE(burst); - VIR_FREE(floor); - return ret; } =20 @@ -119,7 +114,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, virNetDevBandwidthPtr def =3D NULL; xmlNodePtr cur; xmlNodePtr in =3D NULL, out =3D NULL; - char *class_id_prop =3D NULL; + g_autofree char *class_id_prop =3D NULL; =20 def =3D g_new0(virNetDevBandwidth, 1); =20 @@ -210,7 +205,6 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, ret =3D 0; =20 cleanup: - VIR_FREE(class_id_prop); virNetDevBandwidthFree(def); return ret; } --=20 2.29.2 From nobody Sat May 4 23:49:43 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=1614085525; cv=none; d=zohomail.com; s=zohoarc; b=IEi4aCdHLxdMp1MrR3lyHDGgu3785dfBWNy/4WSIc+uuVgUhMovT1OoNR8yG0lfIK9Jpqv7YS8CSKwSA5pYhkbMMNqbz6EOvFpOWPhfKUyhkYGrVdYFMNNMreBf9CK/r5bTRPqwII+ZRjGlZ9ua0gnYwB+WXaB1ceQl+yWhsSP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614085525; 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=v23/vch+Iyn4Z740X+mnMcA9hTGc5WadZF/pEgPlIkc=; b=m/vWpJTaHw7QS0ea76LgxVENP+eSaqzqD5iJFAcTUD+W1KwmMhG8ekBVoxTfNe8/PSU8GWh1M12wGCBo2XS7JjyOjWfGuQlif5m2NBjPajWnQ7gl2/yvenl/iNPko9lz1Kgx1x4R2ShDR3OK2JRUzGGY/w2rbMSaF0OG8Ef/dFo= 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) header.from= 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 161408552471362.52989468095916; Tue, 23 Feb 2021 05:05:24 -0800 (PST) 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-14-g0p_y9hBM02kiuODeg1cyQ-1; Tue, 23 Feb 2021 08:05:20 -0500 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 C58931936B66; Tue, 23 Feb 2021 13:05:14 +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 6EB0019C46; Tue, 23 Feb 2021 13:05:14 +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 EE18458074; Tue, 23 Feb 2021 13:05:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11ND5B90010235 for ; Tue, 23 Feb 2021 08:05:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id AA90A60C47; Tue, 23 Feb 2021 13:05:11 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC96160C04 for ; Tue, 23 Feb 2021 13:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614085523; 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=v23/vch+Iyn4Z740X+mnMcA9hTGc5WadZF/pEgPlIkc=; b=ciUvT4/FK1i0scIGffwJW3BRipv/1d4xLPnOnpOLOc60VXT4tBNikD/z+CPNf50WtmcFTD QqOU/A0Vf+Zua5dqPKgomnxb3P4wQ/JFyZquc0aFyxrtu8jAVqcmLx+WkQQHraKrV8eDtq J6kvrdQjDFvx0+hOrwnC4nltXsQvKTw= X-MC-Unique: g0p_y9hBM02kiuODeg1cyQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 3/4] Use g_autoptr instead of virNetDevBandwidthFree where possible Date: Tue, 23 Feb 2021 14:04:47 +0100 Message-Id: <8a2304b925cc9d8842cdc1cf3117d55653004b49.1614085265.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In files: netdev_bandwidth_conf: in virNetDevBandwidthParse(), bridge_driver: in networkPortSetParameters(), qemu_driver: in qemuDomainSetInterfaceParameters(), test_driver: in testDomainSetInterfaceParameters(), virnetdevbandwidthtest: in testVirNetDevBandwidthSet() Signed-off-by: Kristina Hanicova --- src/conf/netdev_bandwidth_conf.c | 9 +++------ src/network/bridge_driver.c | 6 ++---- src/qemu/qemu_driver.c | 11 ++++------- src/test/test_driver.c | 3 +-- src/util/virnetdevbandwidth.h | 2 ++ tests/virnetdevbandwidthtest.c | 3 +-- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 1ff3785677..81590efe6d 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -111,7 +111,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, bool allowFloor) { int ret =3D -1; - virNetDevBandwidthPtr def =3D NULL; + g_autoptr(virNetDevBandwidth) def =3D NULL; xmlNodePtr cur; xmlNodePtr in =3D NULL, out =3D NULL; g_autofree char *class_id_prop =3D NULL; @@ -197,15 +197,12 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwi= dth, } } =20 - if (!def->in && !def->out) - VIR_FREE(def); + if (def->in || def->out) + *bandwidth =3D g_steal_pointer(&def); =20 - *bandwidth =3D def; - def =3D NULL; ret =3D 0; =20 cleanup: - virNetDevBandwidthFree(def); return ret; } =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 519a473995..b29c37ef4c 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5397,7 +5397,7 @@ networkPortSetParameters(virNetworkPortPtr port, virNetworkObjPtr obj; virNetworkDefPtr def; virNetworkPortDefPtr portdef; - virNetDevBandwidthPtr bandwidth =3D NULL; + g_autoptr(virNetDevBandwidth) bandwidth =3D NULL; g_autofree char *dir =3D NULL; int ret =3D -1; size_t i; @@ -5466,15 +5466,13 @@ networkPortSetParameters(virNetworkPortPtr port, goto cleanup; =20 virNetDevBandwidthFree(portdef->bandwidth); - portdef->bandwidth =3D bandwidth; - bandwidth =3D NULL; + portdef->bandwidth =3D g_steal_pointer(&bandwidth); =20 if (virNetworkPortDefSaveStatus(portdef, dir) < 0) goto cleanup; =20 ret =3D 0; cleanup: - virNetDevBandwidthFree(bandwidth); virNetworkObjEndAPI(&obj); return ret; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b9bbdf8d48..2a191232a6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10207,7 +10207,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, virDomainDefPtr persistentDef; int ret =3D -1; virDomainNetDefPtr net =3D NULL, persistentNet =3D NULL; - virNetDevBandwidthPtr bandwidth =3D NULL, newBandwidth =3D NULL; + g_autoptr(virNetDevBandwidth) bandwidth =3D NULL; + g_autoptr(virNetDevBandwidth) newBandwidth =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; bool inboundSpecified =3D false, outboundSpecified =3D false; int actualType; @@ -10375,8 +10376,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, =20 virNetDevBandwidthFree(net->bandwidth); if (newBandwidth->in || newBandwidth->out) { - net->bandwidth =3D newBandwidth; - newBandwidth =3D NULL; + net->bandwidth =3D g_steal_pointer(&newBandwidth); } else { net->bandwidth =3D NULL; } @@ -10394,8 +10394,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, =20 if (persistentNet) { if (!persistentNet->bandwidth) { - persistentNet->bandwidth =3D bandwidth; - bandwidth =3D NULL; + persistentNet->bandwidth =3D g_steal_pointer(&bandwidth); } else { if (bandwidth->in) { VIR_FREE(persistentNet->bandwidth->in); @@ -10423,8 +10422,6 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, qemuDomainObjEndJob(driver, vm); =20 cleanup: - virNetDevBandwidthFree(bandwidth); - virNetDevBandwidthFree(newBandwidth); virDomainObjEndAPI(&vm); return ret; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bca1297d1d..0ac03de127 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3446,7 +3446,7 @@ testDomainSetInterfaceParameters(virDomainPtr dom, virDomainObjPtr vm =3D NULL; virDomainDefPtr def; virDomainNetDefPtr net =3D NULL; - virNetDevBandwidthPtr bandwidth =3D NULL; + g_autoptr(virNetDevBandwidth) bandwidth =3D NULL; bool inboundSpecified =3D false; bool outboundSpecified =3D false; size_t i; @@ -3536,7 +3536,6 @@ testDomainSetInterfaceParameters(virDomainPtr dom, =20 ret =3D 0; cleanup: - virNetDevBandwidthFree(bandwidth); virDomainObjEndAPI(&vm); return ret; } diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h index 871d0c962c..fff83222a9 100644 --- a/src/util/virnetdevbandwidth.h +++ b/src/util/virnetdevbandwidth.h @@ -38,6 +38,8 @@ struct _virNetDevBandwidth { =20 void virNetDevBandwidthFree(virNetDevBandwidthPtr def); =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetDevBandwidth, virNetDevBandwidthFree); + int virNetDevBandwidthSet(const char *ifname, const virNetDevBandwidth *bandwidth, bool hierarchical_class, diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 5cbdd6ffea..2e76af3d0c 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -69,7 +69,7 @@ testVirNetDevBandwidthSet(const void *data) int ret =3D -1; const struct testSetStruct *info =3D data; const char *iface =3D info->iface; - virNetDevBandwidthPtr band =3D NULL; + g_autoptr(virNetDevBandwidth) band =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *actual_cmd =3D NULL; =20 @@ -98,7 +98,6 @@ testVirNetDevBandwidthSet(const void *data) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virNetDevBandwidthFree(band); VIR_FREE(actual_cmd); return ret; } --=20 2.29.2 From nobody Sat May 4 23:49:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1614085525; cv=none; d=zohomail.com; s=zohoarc; b=lTr1XC04km7+BK4NMR0yufW4OuQU+PQe62THKgGh7/oPfDLsD1qPv8FaHsVAbfqSsxru9l4ZV6f7uenTVJXUwnQowFXo2k+A1XO7ukP+deWsR2hOp8JyNrtInLaQPCZTi9i+Sb2/Shv84Os1l4+x85nvUAb7EWLptuyKK2U2jiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614085525; 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=1wchWPQzJBvVduNyq4EohNZJigijFvdLoP4N0mwKdOg=; b=ElMfx4+JqmP4mhQGI26QVDqAEEKPrwGxl80TmrqBj1KNBUL0fSmtWPUp56oHsbx4PNd8h4WtpquSq99+k8/3ZqH35Ip9QnhV5sQIyJAasosLU4vCTndCWT3FOhh7VGRW6/tfyU2hzHnzpkp7G/lZ+o05eptx6LAW/K5lfvgVhzs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1614085525397939.3146141364042; Tue, 23 Feb 2021 05:05:25 -0800 (PST) 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-439-Y0tmc6x-MGSLmsGb_rfbIg-1; Tue, 23 Feb 2021 08:05:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AA231E563; Tue, 23 Feb 2021 13:05:16 +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 F16515D6BA; Tue, 23 Feb 2021 13:05: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 A85EC58074; Tue, 23 Feb 2021 13:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11ND5EYe010248 for ; Tue, 23 Feb 2021 08:05:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8926060C47; Tue, 23 Feb 2021 13:05:14 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD09C60C04 for ; Tue, 23 Feb 2021 13:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614085524; 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=1wchWPQzJBvVduNyq4EohNZJigijFvdLoP4N0mwKdOg=; b=jRwqhbszVig6PQjHPm1bW3thXCsImk37coYdbnDlc2T0A7ABUsTEw8vovSI0BKliWGJJJI eWT8vm5DHucnHjWLi/a6/f1ExLHdSwNm8VSm+kRfpyIQgl3R54eMzEofRfFGbqlpvNORaA 89p6tNF0YMgwLbrE0cyNbAmQdmG+afM= X-MC-Unique: Y0tmc6x-MGSLmsGb_rfbIg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 4/4] netdev_bandwidth_conf: Remove redundant variables/labels Date: Tue, 23 Feb 2021 14:04:48 +0100 Message-Id: <0361f33eb869fc1238e066a6da64e7268892fd86.1614085265.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.15 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In functions: virNetDevBandwidthParseRate(), virNetDevBandwidthParse() Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/conf/netdev_bandwidth_conf.c | 42 +++++++++++++------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 81590efe6d..13abca94ec 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -28,7 +28,6 @@ static int virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rat= e) { - int ret =3D -1; g_autofree char *average =3D NULL; g_autofree char *peak =3D NULL; g_autofree char *burst =3D NULL; @@ -50,45 +49,42 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevB= andwidthRatePtr rate) virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert bandwidth average value '%= s'"), average); - goto cleanup; + return -1; } } else if (!floor) { virReportError(VIR_ERR_XML_DETAIL, "%s", _("Missing mandatory average or floor attributes")); - goto cleanup; + return -1; } =20 if ((peak || burst) && !average) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("'peak' and 'burst' require 'average' attribute")= ); - goto cleanup; + return -1; } =20 if (peak && virStrToLong_ullp(peak, NULL, 10, &rate->peak) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert bandwidth peak value '%s'"), peak); - goto cleanup; + return -1; } =20 if (burst && virStrToLong_ullp(burst, NULL, 10, &rate->burst) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert bandwidth burst value '%s'"), burst); - goto cleanup; + return -1; } =20 if (floor && virStrToLong_ullp(floor, NULL, 10, &rate->floor) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert bandwidth floor value '%s'"), floor); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 /** @@ -110,7 +106,6 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, xmlNodePtr node, bool allowFloor) { - int ret =3D -1; g_autoptr(virNetDevBandwidth) def =3D NULL; xmlNodePtr cur; xmlNodePtr in =3D NULL, out =3D NULL; @@ -121,7 +116,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, if (!node || !virXMLNodeNameEqual(node, "bandwidth")) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("invalid argument supplied")); - goto cleanup; + return -1; } =20 class_id_prop =3D virXMLPropString(node, "classID"); @@ -130,13 +125,13 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwi= dth, virReportError(VIR_ERR_XML_DETAIL, "%s", _("classID attribute not supported on " "in this usage context")); - goto cleanup; + return -1; } if (virStrToLong_ui(class_id_prop, NULL, 10, class_id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse class id '%s'"), class_id_prop); - goto cleanup; + return -1; } } =20 @@ -149,7 +144,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, virReportError(VIR_ERR_XML_DETAIL, "%s", _("Only one child " "element allowed")); - goto cleanup; + return -1; } in =3D cur; } else if (virXMLNodeNameEqual(cur, "outbound")) { @@ -157,7 +152,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, virReportError(VIR_ERR_XML_DETAIL, "%s", _("Only one child " "element allowed")); - goto cleanup; + return -1; } out =3D cur; } @@ -171,13 +166,13 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwi= dth, =20 if (virNetDevBandwidthParseRate(in, def->in) < 0) { /* helper reported error for us */ - goto cleanup; + return -1; } =20 if (def->in->floor && !allowFloor) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("floor attribute is not supported for this co= nfig")); - goto cleanup; + return -1; } } =20 @@ -186,24 +181,21 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwi= dth, =20 if (virNetDevBandwidthParseRate(out, def->out) < 0) { /* helper reported error for us */ - goto cleanup; + return -1; } =20 if (def->out->floor) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("'floor' attribute allowed " "only in element")); - goto cleanup; + return -1; } } =20 if (def->in || def->out) *bandwidth =3D g_steal_pointer(&def); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int --=20 2.29.2