From nobody Sun May 19 00:42:51 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=1614768527; cv=none; d=zohomail.com; s=zohoarc; b=NutwEsLCWllujFelTcVbVA//zbjQo4JqnJJP0pYIwgXwxwhvpyOBp2pa5f/HLiWx+JRe3Lm8j1pcfY8fJFgUzr77OXGiD9hwmeYN6vQL5R0zVSRdgjTI9hSa/WSXKcalZtphII6cd31jqkpfJDqdbsrTvQ5V54lY1CgUsAEZfdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614768527; 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=g6ZWEBgjgXXDeeHrUPGmKgSBBfioygR4bWCBMAhXBis=; b=WhOM+UYzJ5F0tqsTAqjN6BaIN7LkmB0NuIkW4DyI6AyujVC5Do78LAS3loGBLRIljz9FHloKh5gxIOHKthewZIoBJjpIo9RiYiiwTVgLidpRulW4LopbdSdzoa8+MukTQOEanBH9Wlo95QFYTICtOsLd8wabAeXgb0zs4STlKyQ= 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 161476852741265.02649365962054; Wed, 3 Mar 2021 02:48:47 -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-262-vRBHAyMtO_a3XLZJLT5PcQ-1; Wed, 03 Mar 2021 05:48:44 -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 8179E107ACC7; Wed, 3 Mar 2021 10:48:39 +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 301D65D768; Wed, 3 Mar 2021 10:48:39 +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 E8AD518095CE; Wed, 3 Mar 2021 10:48:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123AmcJS028382 for ; Wed, 3 Mar 2021 05:48:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 160335D9D7; Wed, 3 Mar 2021 10:48:38 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 719D15D9C6 for ; Wed, 3 Mar 2021 10:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614768526; 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=g6ZWEBgjgXXDeeHrUPGmKgSBBfioygR4bWCBMAhXBis=; b=am4pDnBrEPCUdGPEY1yvknT9vh6LLtO2L1DCwx1SMYD2fH5BhgBJV3yqtVS4R9dVCuxYWY hVYj8Py9z1WfD2VZY5Iyn89ZYQcVwH54uFlPijy9Y7Cba3vB3Pk4uzNBkIqDj4HHLjoPRX PBHIYOhG5Ry6EESS7I8IAcW4/F1igBA= X-MC-Unique: vRBHAyMtO_a3XLZJLT5PcQ-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 1/6] vsh-table: Use g_autofree where possible Date: Wed, 3 Mar 2021 11:48:15 +0100 Message-Id: <1b0dc1fdebc790d587b8d1523ef403736ced2483.1614767297.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: vshTableRowNew(), vshTablePrint(), vshTablePrintToStdout(). Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko reviewed-by and I am sending them for completness. --- tools/vsh-table.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/vsh-table.c b/tools/vsh-table.c index d09cc9e14e..c5e57c0d7b 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,7 +359,7 @@ vshTablePrint(vshTablePtr table, bool header) { size_t i; size_t j; - size_t *maxwidths; + g_autofree size_t *maxwidths =3D NULL; size_t **widths; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *ret =3D NULL; @@ -395,7 +393,6 @@ 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); @@ -416,15 +413,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 Sun May 19 00:42:51 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=1614768531; cv=none; d=zohomail.com; s=zohoarc; b=egROmrndo5Kp1cO4RzAwgFFfBJTiilvxcAkpaWFTXsTNhqzyOzZOTSbgFSZL+e2WzuqqSMyn4CWMe6Syfb598aBn05JPYdBbhQ5soXPl3nqtUH4GUd9mKTdIzaFOd8fGvl3D3XHzhkzgth0ka5iaEJLEUKNJu/X9crmkDsuGfCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614768531; 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=WGjjO18nO8i5qrqN80aA8vm1PgZenFSEVbAcAJXoNGk=; b=CL3f12e1wvrLM0h9/yC3folZm2skQ8kUWe2lb9oa3OY4msc6/SwODUrTVqmCxRdYyt52G9TdVHW70jmnm3TKMqVRWzyr6VcfO1397CX+uDifdt2trJwp2jyu604sdHIehjlDYZkVeA+CVv+DuxE0ft0vhvseOwxEiRIjej+zEpQ= 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 1614768531586836.5883584512957; Wed, 3 Mar 2021 02:48:51 -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-469-LArTCWlhNE-rwCmIQzltbg-1; Wed, 03 Mar 2021 05:48:48 -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 ACF9D1E562; Wed, 3 Mar 2021 10:48:42 +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 82FE719D9D; Wed, 3 Mar 2021 10:48:42 +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 491501809C91; Wed, 3 Mar 2021 10:48:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123Amewb028399 for ; Wed, 3 Mar 2021 05:48:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 528B45D9DD; Wed, 3 Mar 2021 10:48:40 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE2BA5D9D7 for ; Wed, 3 Mar 2021 10:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614768530; 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=WGjjO18nO8i5qrqN80aA8vm1PgZenFSEVbAcAJXoNGk=; b=hlpG1TUbMdDOFo0NT5qpBC0UCnsSW6iChdw7YdXTX6oXrhR9PQHRFFnHJYMxN+314KjC/1 pO2xEf448R58VOl+cgA1BBKpAXFXQLaDxidJnh+yi9eE/YnOyVpCcwWj5tnb5/zjKp3Cm2 Ab5E52oyrvGTuu4DUbjkoIgNXMyS6iE= X-MC-Unique: LArTCWlhNE-rwCmIQzltbg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 2/6] netdev_bandwidth_conf: Use g_autofree where possible Date: Wed, 3 Mar 2021 11:48:16 +0100 Message-Id: <69e283f6cdae96f9622eb567118ca130cfe206dc.1614767297.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko reviewed-by and I am sending them for completness. --- 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 Sun May 19 00:42:51 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=1614768532; cv=none; d=zohomail.com; s=zohoarc; b=MBRByrYsYodsGrKQ531d4xcPokQlLHlcvn/xgmbl5g/2yaskWMObuCiPao9XT+syfp4lmzpMDf1ixfZkV2G+sIcK2zDan8/2Tghr1cwRg4sJhCdRRB/DI7Rbb2/dG8C3utn14nkumNTlqkYSkeo/k976N3yfEtWFKB8S3UnptV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614768532; 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=bppVA7dtb3vH9JaedUrXrFtEWzdvnJBj4HjQ99RdUWc=; b=SGpscoh4Tdqc9G5fHrfBLt5UcJZvLi2EvKNEq8zHnxKH4TYCPLLpmsolUVmZXfcHDhsWAPGKnt8rxEB/3tN3QPmrT5macRL/bY2pFJg/g+7NFj0IC3hjZk2VEC8vI3oqKoeQjKGIJ78s5NvLLH+anbCeIsFYjs03oGAp+D2y+GY= 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 1614768532678543.9058786650177; Wed, 3 Mar 2021 02:48:52 -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-31-HYYSDJFTOYSUaXYbLoZ9og-1; Wed, 03 Mar 2021 05:48:49 -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 0A67210066F0; Wed, 3 Mar 2021 10:48:44 +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 D9B5266FFF; Wed, 3 Mar 2021 10:48:43 +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 9F72E18089CB; Wed, 3 Mar 2021 10:48:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123Amg9S028415 for ; Wed, 3 Mar 2021 05:48:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76F225D9DD; Wed, 3 Mar 2021 10:48:42 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id D49C45D9D7 for ; Wed, 3 Mar 2021 10:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614768531; 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=bppVA7dtb3vH9JaedUrXrFtEWzdvnJBj4HjQ99RdUWc=; b=QKDpiPh657/gd8zygfLs7MW0oZTglvVUe5CAC/MaUWyKImjTHd7knl9xWdLJ15q1FAX+Bt Nyw5CsXh+xT+k9fSezDk5MOyFFLtw5XQasirjEPct8b1fPBTKUr9xEjzmgEhipn65wPrLy dFLmjeehfbcqBj+XnlevVN71jiRwXTU= X-MC-Unique: HYYSDJFTOYSUaXYbLoZ9og-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 3/6] netdev_bandwidth_conf: Refractor virNetDevBandwidthParse() Date: Wed, 3 Mar 2021 11:48:17 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" Refractoring includes: * removal of VIR_FREE * inversion of the condition * use of g_steal_pointer Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko reviewed-by and I am sending them for completness. --- src/conf/netdev_bandwidth_conf.c | 9 +++------ src/util/virnetdevbandwidth.h | 2 ++ 2 files changed, 5 insertions(+), 6 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/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, --=20 2.29.2 From nobody Sun May 19 00:42:51 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=1614768538; cv=none; d=zohomail.com; s=zohoarc; b=V9w9BzP6WaKKRBrHGd3HkkVh9zusKzh/djjXIDg0amyzjbWw2eAbORV0HRXH/3c8M6AvzYb4jRMGQproBnnkfIMrOfU2xSg9Y1UYEJfDgHyrmx4gVXhYbDbqtmbkgq6YC4W+DV5YnoKMSL1UBcO8gAw/GyNJl8nrAzqw+VoUvq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614768538; 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=paTcTuwX5FqzE2Ssnj01jEV4IfaY+Ezll2DtUtsUvMg=; b=MDQ+jYEjLKGMBom+pXY1x1Lv0hcl1L8RgYi6Qin8Mb1cOyQO9rqHjDHXL2aHqjkhJhACWXURNKk+JiM6sV9dIBkRT9+xwFhiH1WrrXvZdIfoGVoMIO07vtNcisRmaGU4nAkpKXYKtgAeuthogBifHUw/dm0P+/T8zUsIaSBE0ro= 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 1614768538041249.87028001969384; Wed, 3 Mar 2021 02:48:58 -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-298-38cBY7zmMs2V_eJy6K60uw-1; Wed, 03 Mar 2021 05:48:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B8AB185A0CE; Wed, 3 Mar 2021 10:48:47 +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 D64BD10013C1; Wed, 3 Mar 2021 10:48:46 +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 9DAC358076; Wed, 3 Mar 2021 10:48:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123AmiIG028426 for ; Wed, 3 Mar 2021 05:48:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 52B0A5D9DD; Wed, 3 Mar 2021 10:48:44 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 938215D9D7 for ; Wed, 3 Mar 2021 10:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614768533; 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=paTcTuwX5FqzE2Ssnj01jEV4IfaY+Ezll2DtUtsUvMg=; b=EbRHv9sloPWRquJOrQxaT/3dA41bcz5FM9jNxlJXpA/mz4+Bj6sCJSxJa4OC53OUDUVN5W uqNu3vWNz02onliqhbhddkEr+rlGVZUA9EL2Ixod/WJxzMeSw8mC67CMPz+cOS1CyPcSCn IlphLjM+ozSrI+JI/omgcdJAHYAaKo4= X-MC-Unique: 38cBY7zmMs2V_eJy6K60uw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 4/6] Use g_steal_pointer where possible Date: Wed, 3 Mar 2021 11:48:18 +0100 Message-Id: <52c037f5c338fec7c1a0241dfa1359f8143c28f8.1614767297.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.22 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 reviewed-by and I am sending them for completness. --- src/network/bridge_driver.c | 3 +-- src/qemu/qemu_driver.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 519a473995..29060139d7 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5466,8 +5466,7 @@ 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; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b9bbdf8d48..b18e46e383 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10375,8 +10375,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 +10393,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); --=20 2.29.2 From nobody Sun May 19 00:42:51 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=1614768539; cv=none; d=zohomail.com; s=zohoarc; b=T2c6nndYeQgXboOVxCURXrVZ+1dVKfXIxqvXIYnfqy3e4IDZFU4+jXjhAvidqNjse4DGmY7tXxImHzD2xC8izcET2xhlfncTzFJD3+nmyuvSbq78JyNVeh91ceS74Q4bcNJ5gzakc6JR3A+OGY8L+4kWo+J0k8wD9OcQhO7XI1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614768539; 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=XCIGljerh8iJfWRBMArNwdR/+ERZUcn1/vFEIBJ+0rc=; b=c81THoZTb3MhN4nPlQVlzTyrw1QlK7oCXVqVvRqKrKL/kJX/w1ndG0vJ+lrv808zzuILv2XMk5X/2qeVDbCkSixUzoDGd7W7IG9HMAqqXQUQkECSebqaEMWW/PZOwrKYh0fMyL9i0vmdMrBTz+8uJq2+4dTgZHZtVanS6T7N6z8= 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 1614768539834896.3168096878592; Wed, 3 Mar 2021 02:48:59 -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-603-7KCSLnEgPGmrFEnJ5fxn5g-1; Wed, 03 Mar 2021 05:48:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B191C107ACE3; Wed, 3 Mar 2021 10:48:50 +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 8889710016FF; Wed, 3 Mar 2021 10:48:50 +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 4F6FB1809C91; Wed, 3 Mar 2021 10:48:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123AmneV028438 for ; Wed, 3 Mar 2021 05:48:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3C87A5D9E8; Wed, 3 Mar 2021 10:48:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 916A95D9DD for ; Wed, 3 Mar 2021 10:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614768538; 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=XCIGljerh8iJfWRBMArNwdR/+ERZUcn1/vFEIBJ+0rc=; b=caIN+xh7xOr1MMq9/3P7Hm8kDHfjMq131abNA6Ed7/TMPU3XP6Ym6yayjfZmkeF6Ue/2yg GJdC+Z+oOsivwS/D/reRq762Tdgj8m/gVnNuqMiVx6rzGW/M4JqzkNEoz1lPr/vXcPX8wq jFD6uwhA7NdPruYOTt+Tfilyoz/jw9k= X-MC-Unique: 7KCSLnEgPGmrFEnJ5fxn5g-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 5/6] Use g_autoptr instead of virNetDevBandwidthFree where possible Date: Wed, 3 Mar 2021 11:48:19 +0100 Message-Id: <8aed13434be3e899d38c81edb09154fbe27e2b07.1614767298.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.22 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 reviewed-by and I am sending them for completness. --- src/network/bridge_driver.c | 3 +-- src/qemu/qemu_driver.c | 5 ++--- src/test/test_driver.c | 3 +-- tests/virnetdevbandwidthtest.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 29060139d7..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; @@ -5473,7 +5473,6 @@ networkPortSetParameters(virNetworkPortPtr port, =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 b18e46e383..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; @@ -10421,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/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 Sun May 19 00:42:51 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=1614768623; cv=none; d=zohomail.com; s=zohoarc; b=SydEbZV1KGkR7p58xf//Hc1xXUpLcy2yo/tlkmbCCJv2YTlfX/jEYIbSJwjD/cBff9oEJYspAvJE7q+V4Lh/A+4dbSkU+Viz4UPz5DHOLigOiE5zc4KNWOCbyLrO/QBjcFOaXFKlF92vQfmUvy5aJQX5VdqiAUaXgyEq7n2WpAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614768623; 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=DMF/oiIM3EEInrGgCTwh/BKXC4zOoqy/RliCaK5frcc=; b=OTMHqr30X0xN0EvLWkUAkVE374/X+ridbzMKtnbwZJ1ThdggnLvJq48tIKKfA44+3VVOIm50FVALJPbgCq0JXe9qCvcvtWbgU2gqARMYho2Q5IQJLzusVQrRvaV1QRZc23v8zyfFwwD/cQqHB8lXs8nRJbDTaL8LCFvHFp+D+bQ= 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 1614768623078972.3625036308825; Wed, 3 Mar 2021 02:50:23 -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-414-lC0Nsm_mNhGQfZl-A9Ug9Q-1; Wed, 03 Mar 2021 05:49:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D63C8030CC; Wed, 3 Mar 2021 10:48:55 +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 597315F722; Wed, 3 Mar 2021 10:48:55 +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 1AFF258076; Wed, 3 Mar 2021 10:48:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 123Amq7V028461 for ; Wed, 3 Mar 2021 05:48:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 962E55D9E2; Wed, 3 Mar 2021 10:48:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9B0C5D9DD for ; Wed, 3 Mar 2021 10:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614768622; 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=DMF/oiIM3EEInrGgCTwh/BKXC4zOoqy/RliCaK5frcc=; b=AyGwiuadpKKEx+75gYTuEjYlS1vYQ4ebNRJfhrT67dmkl7cWZ0dkwboJ1C1jJJ2s9f4Z/0 nnr7GTOAYnkKrOIGZ4WPQs2KTeZZeXpBLesfMGaHytvKRZ4IdcWPF7juqRvm6yNe8TIQG3 g2XEViWf80632Wa2DVp2wtDS/ha1Lxg= X-MC-Unique: lC0Nsm_mNhGQfZl-A9Ug9Q-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 6/6] netdev_bandwidth_conf: Remove redundant variables/labels Date: Wed, 3 Mar 2021 11:48:20 +0100 Message-Id: <3de2777622a83641be6c4bbf6ed8fad715ee3bb3.1614767298.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.16 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) In functions: virNetDevBandwidthParseRate(), virNetDevBandwidthParse() Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko reviewed-by and I am sending them for completness. --- 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