From nobody Sat Apr 20 09:14:34 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=1642171227; cv=none; d=zohomail.com; s=zohoarc; b=Vqi7F8E6SN8299OWvZAZjOQjkEoKlGw+WTyz40sY/yla8qXyDZ6uzW2SkaeyQjrO/jbySOwR4fc8mNlJmo7w6ArD45/icCh807X++Xsl5fhAvFAs7xIa0WcuYCF7ZwUpNbmfGBVAqZ7nMRICsTWxTyGbnDFw81DP+c7UfN4iR8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171227; 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=e2qwRbmp1qMZYqbAoXzrZi0wrBV+1U3DuTOxK0Ypie0=; b=hLX1XZhWRDJqNxsrNqWv9QC3azBYANjSFj2TdXoBwESbQ9WB8IQ4XNgWsq2UdLUuZoU+sv8ANi1m6BQ1sht7yR9Hzol69C4yV41bA/GOXYkaO+XUN1zUT4/r4ZoKy2FjNfs6BhUE6CI5V16+nJ+fS9EJ/jqsHAFbMg0B6yr3sXM= 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 1642171227624895.7475795596515; Fri, 14 Jan 2022 06:40:27 -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-308-1M8FtY8EM5ufMSSm5BcNOw-1; Fri, 14 Jan 2022 09:40:25 -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 4E03610144EA; Fri, 14 Jan 2022 14:40: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 2A32C7E2F3; Fri, 14 Jan 2022 14:40: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 E7CFD18077BC; Fri, 14 Jan 2022 14:40:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEe8bE029209 for ; Fri, 14 Jan 2022 09:40:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id DDABA7B6ED; Fri, 14 Jan 2022 14:40:08 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50C8E7B6EB for ; Fri, 14 Jan 2022 14:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171226; 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=e2qwRbmp1qMZYqbAoXzrZi0wrBV+1U3DuTOxK0Ypie0=; b=Nb1blkG+UaLQ9Zga2fbawpBBN/87GPqET4zNYkVPuTj166FO5cOYCc7FFwPhAE11oSjJbI OgPIlsgp7cGk/EwRbVaT5/Ksm2TAXVuX1ZZVCGsblWb7f0wf2JxhouioolHAqVf2PCpCH8 x+b2iJvB/43tigchtpM1Fbx2BzAcNQM= X-MC-Unique: 1M8FtY8EM5ufMSSm5BcNOw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/11] storage_file: Declare virStorageSourceParseRBDColonString only in one header Date: Fri, 14 Jan 2022 15:39:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171228250100001 Content-Type: text/plain; charset="utf-8" The virStorageSourceParseRBDColonString() function is declared in src/storage_file/storage_source.h and src/storage_file/storage_source_backingstore.h but implemented only in the .c that corresponds to the latter header file. Therefore, drop declaration from storage_source.h as the function is not implemented in its corresponding .c file. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/libxl/xen_xl.c | 1 + src/storage_file/storage_source.h | 5 ----- src/storage_file/storage_source_backingstore.h | 3 ++- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 7604e3d534..94268fb76d 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -30,6 +30,7 @@ #include "viralloc.h" #include "virstring.h" #include "storage_source.h" +#include "storage_source_backingstore.h" #include "xen_xl.h" #include "libxl_capabilities.h" #include "libxl_conf.h" diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_s= ource.h index 5aaf4c356a..0ae06f4e7d 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -66,11 +66,6 @@ int virStorageSourceNewFromBacking(virStorageSource *parent, virStorageSource **backing); =20 -int -virStorageSourceParseRBDColonString(const char *rbdstr, - virStorageSource *src) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - int virStorageSourceGetRelativeBackingPath(virStorageSource *top, virStorageSource *base, diff --git a/src/storage_file/storage_source_backingstore.h b/src/storage_f= ile/storage_source_backingstore.h index f5ec8e9154..e7e2a58eb9 100644 --- a/src/storage_file/storage_source_backingstore.h +++ b/src/storage_file/storage_source_backingstore.h @@ -29,7 +29,8 @@ virStorageSourceParseBackingURI(virStorageSource *src, =20 int virStorageSourceParseRBDColonString(const char *rbdstr, - virStorageSource *src); + virStorageSource *src) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int virStorageSourceParseBackingColon(virStorageSource *src, --=20 2.34.1 From nobody Sat Apr 20 09:14:34 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=1642171221; cv=none; d=zohomail.com; s=zohoarc; b=FB5fxtHMFgWdKzuSitLL/yaUlylHYsIIk8cQBMRqU8BAuFjSp1IUxhs5lk3wA1EcgoCuSZYvoav1kooIZKWt2jyz7YdgcIWmKOAN+a3Ut3ZfdctwHoE7Aofd0s4cJOOiK0k8RmzW0sN7khedradtlRqzSLxTKa1bWKkzV6nb19I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171221; 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=c2p031f8FPt0deN/0nf870mW4CQM6rRvizCrDPAPnks=; b=lhAGMrlN5DRr4AfVvkfeHMiv2c64G66UjIfuCTorYog36Z/IdQba4Pngx11SHi6+D9k43I6nbfrsHZc4K4Iwe+JrDK6BHlrFTE7wraJpUdySCZniVEqxI2OeFCoBss2fMibnPR8orMKyJKhOwXD3WatH4VhglEyVdkyblz6akjY= 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 1642171221085402.16533458346385; Fri, 14 Jan 2022 06:40: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-306-yu-eA1abOj2uHSr4Q9SBhQ-1; Fri, 14 Jan 2022 09:40:18 -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 7334B874981; Fri, 14 Jan 2022 14:40:13 +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 4AB6B77440; Fri, 14 Jan 2022 14:40:13 +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 12D514CA9B; Fri, 14 Jan 2022 14:40:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEe92u029220 for ; Fri, 14 Jan 2022 09:40:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id BAA337B6ED; Fri, 14 Jan 2022 14:40:09 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39E027B6EB for ; Fri, 14 Jan 2022 14:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171219; 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=c2p031f8FPt0deN/0nf870mW4CQM6rRvizCrDPAPnks=; b=V4ZjHhnE68JnJudGlDKiDBm46rVwixBDMvRrmSIdyBX095T3E21tRRK/lH60L/9wVKZ6hJ CHcqQU9kW6DKYBvgaaBj3aHSlR6UOijsOwIwW+KUf/GBj0qz5DoNEis6AWSd2l12Vejdcy wrdTA2Y/WnvjEHJBKZ3POe5yJlXF3DE= X-MC-Unique: yu-eA1abOj2uHSr4Q9SBhQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/11] virconf: Report an error in when virConfSetValue() fails Date: Fri, 14 Jan 2022 15:39:46 +0100 Message-Id: <13ebdbe15a4ff30bcf75a12f0657e5e19fc6e0ce.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171223125100003 Content-Type: text/plain; charset="utf-8" Callers of virConfSetValue() don't report any error, they just pass the error blindly. Therefore, report an error when virConfSetValue() is about to fail. Signed-off-by: Michal Privoznik --- src/util/virconf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virconf.c b/src/util/virconf.c index 07ecfc7b57..29b3622791 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -1329,6 +1329,9 @@ virConfSetValue(virConf *conf, virConfEntry *prev =3D NULL; =20 if (value && value->type =3D=3D VIR_CONF_STRING && value->str =3D=3D N= ULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("expecting a value for value of type %s"), + virConfTypeToString(VIR_CONF_STRING)); virConfFreeValue(value); return -1; } --=20 2.34.1 From nobody Sat Apr 20 09:14:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642171222; cv=none; d=zohomail.com; s=zohoarc; b=awaxPQ3GatU5zumzzfxdu7angC1Ph6DNQAXkUDJUugRWU2ZD2N/x4vfQe786mJauTcfHx3vDVTIQrHmvkeboxo7+oHaXHTXqVoR8j/m6lYOWfv8mYOS7Z1l8Sa0x0Z4YGojKesbTJSmg5je4Xo3U0eAGyPAY4GzJVC343p3ZmZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171222; 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=hJddUhjK0R+etYoluMhdAYlKwEPx5+yoaemSiFX62GI=; b=nUIan20R0qTI7FASrpRMz3HofxY5mYbmdRySPqbGs4p8lQXQzxS9Uz8O7MGh7SVMjvvDUJutIJbjfGPFTy9okQC+IogF36KZDgzD1fsFBNjqSivZuwSfhH5x1GT3qVQh6NYa6lPTLcFhaOMT+IrbfK+4FiFxMpZxPy04Lxwx9T0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642171222718898.3033415071851; Fri, 14 Jan 2022 06:40:22 -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-625-i9mKlGVnNM-cNYN1JjBmaQ-1; Fri, 14 Jan 2022 09:40:19 -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 E3BA21054F90; Fri, 14 Jan 2022 14:40:12 +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 B9F27798D5; Fri, 14 Jan 2022 14:40: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 5F2901809CB8; Fri, 14 Jan 2022 14:40:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeAvs029230 for ; Fri, 14 Jan 2022 09:40:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id A0DBA7B6ED; Fri, 14 Jan 2022 14:40:10 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 192F47B6F1 for ; Fri, 14 Jan 2022 14:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171221; 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=hJddUhjK0R+etYoluMhdAYlKwEPx5+yoaemSiFX62GI=; b=iXZqpDW2op+ajk7cedgSGrlN0tf5FGz63lj0hff+G8Z79/k6Vn7/+yZ10fNuOnLvZQQZEs uVRzkku02PVh/XgvI/614Y4CrTHl3+hOgvCsRRF9x3ef6uKPMrp958g3I2N78XvfSw4CDo +lx+fbi2jFPX3sEJjKsXegtSOh3bk/g= X-MC-Unique: i9mKlGVnNM-cNYN1JjBmaQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/11] xen_xl: Check for virConfSetValue() retval Date: Fri, 14 Jan 2022 15:39:47 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171224796100005 Content-Type: text/plain; charset="utf-8" There's one case where the return value of virConfSetValue() is not checked for and it's in xenFormatXLInputDevs() function. Let's fix that. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 94268fb76d..e3ddae8827 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1853,7 +1853,11 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *de= f) goto error; virConfFreeValue(usbdevices); } else { - virConfSetValue(conf, "usbdevice", usbdevices); + if (virConfSetValue(conf, "usbdevice", usbdevices) < 0) { + usbdevices =3D NULL; + goto error; + } + usbdevices =3D NULL; } } else { VIR_FREE(usbdevices); --=20 2.34.1 From nobody Sat Apr 20 09:14:34 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=1642171231; cv=none; d=zohomail.com; s=zohoarc; b=dLkOLVTQ2d+64rezM4XNt3ynwuhzshWSH4WurYBfvL6irFKbbeJumh3WTr8RfbMhQv7S4PUxTY0jXgNTn0oMyv0uyM8KLlx4YLKTfySnvSmmAYAScZpeWhmoTIYeImjFuE+95/ebVcm5kID1xc689r6AqcCxZ2FE2SGVfysWgn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171231; 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=kBdeWAzXdMtra9Ipg8YNYrd/OH9AerOtS66paqwD0g0=; b=bFU/Z07WisQFR9fonnScOQvcSEKYVZxBvTmaZmU47mp936e80pSQO068r/jir34rmwScCE/uE2Ijq8lS0c5HkuePF2dWKnxtYzKplDfVOCZx1NdJWDjFwgg+ZJW7JLo6qIEAA3YuWOYekwiE20ZrFpQ8hLoG5VIfIfXhrjriub4= 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 1642171231152396.0475288332526; Fri, 14 Jan 2022 06:40:31 -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-536-e6YZu2YuNw2S94VBeJolTg-1; Fri, 14 Jan 2022 09:40:26 -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 4823A1054F9B; Fri, 14 Jan 2022 14:40:20 +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 243E510841E7; Fri, 14 Jan 2022 14:40: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 E452A4A7CB; Fri, 14 Jan 2022 14:40:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeBri029235 for ; Fri, 14 Jan 2022 09:40:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 878F17B6ED; Fri, 14 Jan 2022 14:40:11 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 012357B6EB for ; Fri, 14 Jan 2022 14:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171230; 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=kBdeWAzXdMtra9Ipg8YNYrd/OH9AerOtS66paqwD0g0=; b=PeyfeO+jo/u0DkfVbmq0y+cwOHUh4Ck6W7mm8fCr9yNxpw/BQkjVX+vN1xEg9R4fkNCE+G oqQHjfXnNT0h+sHdWFg5Nnh95dhqxu/obWSPuZwDz+w6nvzK4gHSGeZ5AprBVDFYqXad3k /vCFJ51D9mo5mOTx+TsgZ7QIwNF/ZMI= X-MC-Unique: e6YZu2YuNw2S94VBeJolTg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/11] src: Declare and use g_autoptr(virConfValue) Date: Fri, 14 Jan 2022 15:39:48 +0100 Message-Id: <47167d7b7a05ef6d48268690e13a872ef3f147e8.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171232080100003 Content-Type: text/plain; charset="utf-8" This commit declares g_autoptr() function for virConfValue type. At the same time, it switches variable declarations to use it. Also, in a few places we might have freed a variable twice, for instance in xenFormatXLDomainNamespaceData(). This is because virConfSetValue() consumes passed pointer (@value) even in case of failure and thus any code that uses virConfSetValue() must refrain from touching @value and it must not call virConfFreeValue(). This semantic is not obvious and will be addressed in one of future commits. Signed-off-by: Michal Privoznik --- src/libxl/xen_common.c | 28 +++++++++++++--------------- src/libxl/xen_xl.c | 36 +++++++++++++----------------------- src/libxl/xen_xm.c | 4 +--- src/util/virconf.h | 1 + 4 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index e68ca1cde3..f36e269aab 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1729,7 +1729,7 @@ xenFormatNet(virConnectPtr conn, static int xenFormatPCI(virConf *conf, virDomainDef *def) { - virConfValue *pciVal =3D NULL; + g_autoptr(virConfValue) pciVal =3D NULL; int hasPCI =3D 0; size_t i; =20 @@ -1794,7 +1794,6 @@ xenFormatPCI(virConf *conf, virDomainDef *def) if (ret < 0) return -1; } - VIR_FREE(pciVal); =20 return 0; } @@ -1970,7 +1969,7 @@ xenFormatCharDev(virConf *conf, virDomainDef *def, } else { size_t j =3D 0; int maxport =3D -1, port; - virConfValue *serialVal =3D NULL; + g_autoptr(virConfValue) serialVal =3D NULL; =20 if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -1997,7 +1996,6 @@ xenFormatCharDev(virConf *conf, virDomainDef *def, } =20 if (xenFormatSerial(serialVal, chr) < 0) { - VIR_FREE(serialVal); return -1; } } @@ -2009,7 +2007,6 @@ xenFormatCharDev(virConf *conf, virDomainDef *def, if (ret < 0) return -1; } - VIR_FREE(serialVal); } } else { if (xenConfigSetString(conf, "serial", "none") < 0) @@ -2224,8 +2221,8 @@ xenFormatVfb(virConf *conf, virDomainDef *def) return -1; } } else { - virConfValue *vfb; - virConfValue *disp; + g_autoptr(virConfValue) vfb =3D NULL; + g_autoptr(virConfValue) disp =3D NULL; char *vfbstr =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 @@ -2259,16 +2256,19 @@ xenFormatVfb(virConf *conf, virDomainDef *def) =20 vfbstr =3D virBufferContentAndReset(&buf); =20 - vfb =3D g_new0(virConfValue, 1); disp =3D g_new0(virConfValue, 1); - - vfb->type =3D VIR_CONF_LIST; - vfb->list =3D disp; disp->type =3D VIR_CONF_STRING; disp->str =3D vfbstr; =20 - if (virConfSetValue(conf, "vfb", vfb) < 0) + vfb =3D g_new0(virConfValue, 1); + vfb->type =3D VIR_CONF_LIST; + vfb->list =3D g_steal_pointer(&disp); + + if (virConfSetValue(conf, "vfb", vfb) < 0) { + vfb =3D NULL; return -1; + } + vfb =3D NULL; } } =20 @@ -2312,7 +2312,7 @@ xenFormatVif(virConf *conf, virDomainDef *def, const char *vif_typename) { - virConfValue *netVal =3D NULL; + g_autoptr(virConfValue) netVal =3D NULL; size_t i; int hvm =3D def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM; =20 @@ -2333,11 +2333,9 @@ xenFormatVif(virConf *conf, goto cleanup; } =20 - VIR_FREE(netVal); return 0; =20 cleanup: - virConfFreeValue(netVal); return -1; } =20 diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index e3ddae8827..815c1216f7 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1429,7 +1429,7 @@ xenFormatXLDomainVnuma(virConf *conf, virDomainDef *def) { virDomainNuma *numa =3D def->numa; - virConfValue *vnumaVal; + g_autoptr(virConfValue) vnumaVal =3D NULL; size_t i; size_t nr_nodes; =20 @@ -1453,12 +1453,10 @@ xenFormatXLDomainVnuma(virConf *conf, if (ret < 0) return -1; } - VIR_FREE(vnumaVal); =20 return 0; =20 cleanup: - virConfFreeValue(vnumaVal); return -1; } =20 @@ -1683,7 +1681,7 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef = *disk) static int xenFormatXLDomainDisks(virConf *conf, virDomainDef *def) { - virConfValue *diskVal; + g_autoptr(virConfValue) diskVal =3D NULL; size_t i; =20 diskVal =3D g_new0(virConfValue, 1); @@ -1705,12 +1703,10 @@ xenFormatXLDomainDisks(virConf *conf, virDomainDef = *def) if (ret < 0) return -1; } - VIR_FREE(diskVal); =20 return 0; =20 cleanup: - virConfFreeValue(diskVal); return -1; } =20 @@ -1807,7 +1803,7 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *def) { size_t i; const char *devtype; - virConfValue *usbdevices =3D NULL; + g_autoptr(virConfValue) usbdevices =3D NULL; virConfValue *lastdev; =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { @@ -1851,7 +1847,6 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *def) * only one device present */ if (xenConfigSetString(conf, "usbdevice", usbdevices->list= ->str) < 0) goto error; - virConfFreeValue(usbdevices); } else { if (virConfSetValue(conf, "usbdevice", usbdevices) < 0) { usbdevices =3D NULL; @@ -1859,14 +1854,11 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *d= ef) } usbdevices =3D NULL; } - } else { - VIR_FREE(usbdevices); } } =20 return 0; error: - virConfFreeValue(usbdevices); return -1; } =20 @@ -1874,7 +1866,7 @@ static int xenFormatXLUSBController(virConf *conf, virDomainDef *def) { - virConfValue *usbctrlVal =3D NULL; + g_autoptr(virConfValue) usbctrlVal =3D NULL; int hasUSBCtrl =3D 0; size_t i; =20 @@ -1937,12 +1929,10 @@ xenFormatXLUSBController(virConf *conf, if (ret < 0) return -1; } - VIR_FREE(usbctrlVal); =20 return 0; =20 error: - virConfFreeValue(usbctrlVal); return -1; } =20 @@ -1951,7 +1941,7 @@ static int xenFormatXLUSB(virConf *conf, virDomainDef *def) { - virConfValue *usbVal =3D NULL; + g_autoptr(virConfValue) usbVal =3D NULL; int hasUSB =3D 0; size_t i; =20 @@ -2001,7 +1991,6 @@ xenFormatXLUSB(virConf *conf, if (ret < 0) return -1; } - VIR_FREE(usbVal); =20 return 0; } @@ -2050,7 +2039,7 @@ xenFormatXLChannel(virConfValue *list, virDomainChrDe= f *channel) static int xenFormatXLDomainChannels(virConf *conf, virDomainDef *def) { - virConfValue *channelVal =3D NULL; + g_autoptr(virConfValue) channelVal =3D NULL; size_t i; =20 channelVal =3D g_new0(virConfValue, 1); @@ -2075,11 +2064,9 @@ xenFormatXLDomainChannels(virConf *conf, virDomainDe= f *def) goto cleanup; } =20 - VIR_FREE(channelVal); return 0; =20 cleanup: - virConfFreeValue(channelVal); return -1; } =20 @@ -2087,7 +2074,7 @@ static int xenFormatXLDomainNamespaceData(virConf *conf, virDomainDef *def) { libxlDomainXmlNsDef *nsdata =3D def->namespaceData; - virConfValue *args =3D NULL; + g_autoptr(virConfValue) args =3D NULL; size_t i; =20 if (!nsdata) @@ -2118,14 +2105,17 @@ xenFormatXLDomainNamespaceData(virConf *conf, virDo= mainDef *def) args->list =3D val; } =20 - if (args->list !=3D NULL) - if (virConfSetValue(conf, "device_model_args", args) < 0) + if (args->list !=3D NULL) { + if (virConfSetValue(conf, "device_model_args", args) < 0) { + args =3D NULL; goto error; + } + args =3D NULL; + } =20 return 0; =20 error: - virConfFreeValue(args); return -1; } =20 diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 9c2d091918..b8f0471514 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -340,7 +340,7 @@ xenFormatXMDisk(virConfValue *list, static int xenFormatXMDisks(virConf *conf, virDomainDef *def) { - virConfValue *diskVal =3D NULL; + g_autoptr(virConfValue) diskVal =3D NULL; size_t i =3D 0; =20 diskVal =3D g_new0(virConfValue, 1); @@ -362,12 +362,10 @@ xenFormatXMDisks(virConf *conf, virDomainDef *def) if (ret < 0) goto cleanup; } - VIR_FREE(diskVal); =20 return 0; =20 cleanup: - virConfFreeValue(diskVal); return -1; } =20 diff --git a/src/util/virconf.h b/src/util/virconf.h index 937e5d43ed..558009b92e 100644 --- a/src/util/virconf.h +++ b/src/util/virconf.h @@ -78,6 +78,7 @@ virConf *virConfReadString(const char *memory, int virConfFree(virConf *conf); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virConf, virConfFree); void virConfFreeValue(virConfValue *val); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virConfValue, virConfFreeValue); virConfValue *virConfGetValue(virConf *conf, const char *setting); =20 --=20 2.34.1 From nobody Sat Apr 20 09:14:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642171228; cv=none; d=zohomail.com; s=zohoarc; b=fjOoe+VVFvauM276kaLPqlMq0DAM4WMhhed2/egE6eAelXUNodZwcKON48sTozea2FTh9P43mJyETTpMaXYmaiYjTjbx+4cXo2GTdWJwk8PAd3qrix3jEluDoJ2P1jr79CjyV6h6IvjEhACVBjiqZfr67iQbkS4kOF/yffYzdQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171228; 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=4+YefSDuz8clarHVuzN1lo4xUYRIUqLuGq0QN6AieO4=; b=CsyyVumZcxAK9VksiVZoMPd6YxCyrkOxw901amP42VsCNVJ2E98GO0+sX/Gbnhm6jAiUjbXylSiXfUXfhqJuKQ7MRz2aqshy9n63ifUHVtkn1GAtbkXT+S/jpkwl2sH9zf87KV0JapsMtK+yZvd11H9+EmvuZ8t9lzxk8rfqvjI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642171228801304.7717818885716; Fri, 14 Jan 2022 06:40: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-657-cG4qnha8MjmqzofVYJEs_w-1; Fri, 14 Jan 2022 09:40:26 -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 461271054F9A; Fri, 14 Jan 2022 14:40: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 22906106C07F; Fri, 14 Jan 2022 14:40: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 E31A71802E2B; Fri, 14 Jan 2022 14:40:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeCRO029242 for ; Fri, 14 Jan 2022 09:40:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6E68C7B6ED; Fri, 14 Jan 2022 14:40:12 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E17FF7B6EB for ; Fri, 14 Jan 2022 14:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171227; 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=4+YefSDuz8clarHVuzN1lo4xUYRIUqLuGq0QN6AieO4=; b=jG3eWK24mRaeDqIhOGje6c7H5MSJrAZhRtWg/XAm42Ysl8EzFjthOR2kC67JVx3e8uetaO 95WMtB0WfWogAB0RqFzIrPHE82h/SakVX5zzjPdiGOvBxwERD7dhmWXI7XeL7ys5NdbDNg tDJNiG0PaKJvZr7jAsBhyhuoRu0JPF0= X-MC-Unique: cG4qnha8MjmqzofVYJEs_w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/11] virconf: Make virConfSetValue() clear consumed pointer Date: Fri, 14 Jan 2022 15:39:49 +0100 Message-Id: <5dde7d2c209b228120e5ba08333ca6e1ffcfa80a.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171230712100001 Content-Type: text/plain; charset="utf-8" The way that virConfSetValue() works (and the way it is even documented) is that the @value pointer is always consumed. However, since the first order pointer is passed it leaves callers in a pickle situation - they always have to set pointer to NULL after calling virConfSetValue() to avoid touching it. Let's switch @value to a double pointer and clear it inside the function. Signed-off-by: Michal Privoznik --- src/libxl/xen_common.c | 37 +++++++++----------------- src/libxl/xen_xl.c | 60 +++++++++++++----------------------------- src/libxl/xen_xm.c | 9 +++---- src/util/virconf.c | 16 +++++++---- src/util/virconf.h | 2 +- 5 files changed, 46 insertions(+), 78 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index f36e269aab..2d363ac2fb 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -259,7 +259,7 @@ xenConfigSetInt(virConf *conf, const char *setting, lon= g long l) value->next =3D NULL; value->l =3D l; =20 - return virConfSetValue(conf, setting, value); + return virConfSetValue(conf, setting, &value); } =20 =20 @@ -274,7 +274,7 @@ xenConfigSetString(virConf *conf, const char *setting, = const char *str) value->next =3D NULL; value->str =3D g_strdup(str); =20 - return virConfSetValue(conf, setting, value); + return virConfSetValue(conf, setting, &value); } =20 =20 @@ -1788,12 +1788,9 @@ xenFormatPCI(virConf *conf, virDomainDef *def) } } =20 - if (pciVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "pci", pciVal); - pciVal =3D NULL; - if (ret < 0) - return -1; - } + if (pciVal->list !=3D NULL && + virConfSetValue(conf, "pci", &pciVal) < 0) + return -1; =20 return 0; } @@ -2000,13 +1997,9 @@ xenFormatCharDev(virConf *conf, virDomainDef *def, } } =20 - if (serialVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "serial", serialVal); - - serialVal =3D NULL; - if (ret < 0) - return -1; - } + if (serialVal->list !=3D NULL && + virConfSetValue(conf, "serial", &serialVal) < 0) + return -1; } } else { if (xenConfigSetString(conf, "serial", "none") < 0) @@ -2264,11 +2257,8 @@ xenFormatVfb(virConf *conf, virDomainDef *def) vfb->type =3D VIR_CONF_LIST; vfb->list =3D g_steal_pointer(&disp); =20 - if (virConfSetValue(conf, "vfb", vfb) < 0) { - vfb =3D NULL; + if (virConfSetValue(conf, "vfb", &vfb) < 0) return -1; - } - vfb =3D NULL; } } =20 @@ -2326,12 +2316,9 @@ xenFormatVif(virConf *conf, goto cleanup; } =20 - if (netVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "vif", netVal); - netVal =3D NULL; - if (ret < 0) - goto cleanup; - } + if (netVal->list !=3D NULL && + virConfSetValue(conf, "vif", &netVal) < 0) + goto cleanup; =20 return 0; =20 diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 815c1216f7..6e489f35ad 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1447,12 +1447,9 @@ xenFormatXLDomainVnuma(virConf *conf, goto cleanup; } =20 - if (vnumaVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "vnuma", vnumaVal); - vnumaVal =3D NULL; - if (ret < 0) - return -1; - } + if (vnumaVal->list !=3D NULL && + virConfSetValue(conf, "vnuma", &vnumaVal) < 0) + return -1; =20 return 0; =20 @@ -1697,12 +1694,9 @@ xenFormatXLDomainDisks(virConf *conf, virDomainDef *= def) goto cleanup; } =20 - if (diskVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "disk", diskVal); - diskVal =3D NULL; - if (ret < 0) - return -1; - } + if (diskVal->list !=3D NULL && + virConfSetValue(conf, "disk", &diskVal) < 0) + return -1; =20 return 0; =20 @@ -1848,11 +1842,8 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *de= f) if (xenConfigSetString(conf, "usbdevice", usbdevices->list= ->str) < 0) goto error; } else { - if (virConfSetValue(conf, "usbdevice", usbdevices) < 0) { - usbdevices =3D NULL; + if (virConfSetValue(conf, "usbdevice", &usbdevices) < 0) goto error; - } - usbdevices =3D NULL; } } } @@ -1923,12 +1914,9 @@ xenFormatXLUSBController(virConf *conf, } } =20 - if (usbctrlVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "usbctrl", usbctrlVal); - usbctrlVal =3D NULL; - if (ret < 0) - return -1; - } + if (usbctrlVal->list !=3D NULL && + virConfSetValue(conf, "usbctrl", &usbctrlVal) < 0) + return -1; =20 return 0; =20 @@ -1985,12 +1973,9 @@ xenFormatXLUSB(virConf *conf, } } =20 - if (usbVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "usbdev", usbVal); - usbVal =3D NULL; - if (ret < 0) - return -1; - } + if (usbVal->list !=3D NULL && + virConfSetValue(conf, "usbdev", &usbVal) < 0) + return -1; =20 return 0; } @@ -2057,12 +2042,9 @@ xenFormatXLDomainChannels(virConf *conf, virDomainDe= f *def) goto cleanup; } =20 - if (channelVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "channel", channelVal); - channelVal =3D NULL; - if (ret < 0) - goto cleanup; - } + if (channelVal->list !=3D NULL && + virConfSetValue(conf, "channel", &channelVal) < 0) + goto cleanup; =20 return 0; =20 @@ -2105,13 +2087,9 @@ xenFormatXLDomainNamespaceData(virConf *conf, virDom= ainDef *def) args->list =3D val; } =20 - if (args->list !=3D NULL) { - if (virConfSetValue(conf, "device_model_args", args) < 0) { - args =3D NULL; - goto error; - } - args =3D NULL; - } + if (args->list !=3D NULL && + virConfSetValue(conf, "device_model_args", &args) < 0) + goto error; =20 return 0; =20 diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index b8f0471514..f20307430c 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -356,12 +356,9 @@ xenFormatXMDisks(virConf *conf, virDomainDef *def) goto cleanup; } =20 - if (diskVal->list !=3D NULL) { - int ret =3D virConfSetValue(conf, "disk", diskVal); - diskVal =3D NULL; - if (ret < 0) - goto cleanup; - } + if (diskVal->list !=3D NULL && + virConfSetValue(conf, "disk", &diskVal) < 0) + goto cleanup; =20 return 0; =20 diff --git a/src/util/virconf.c b/src/util/virconf.c index 29b3622791..cd45c5f657 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -1323,16 +1323,22 @@ int virConfGetValueULLong(virConf *conf, int virConfSetValue(virConf *conf, const char *setting, - virConfValue *value) + virConfValue **value) { virConfEntry *cur; virConfEntry *prev =3D NULL; =20 - if (value && value->type =3D=3D VIR_CONF_STRING && value->str =3D=3D N= ULL) { + if (!value) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid use of conf API")); + return -1; + } + + if (*value && (*value)->type =3D=3D VIR_CONF_STRING && !(*value)->str)= { virReportError(VIR_ERR_INTERNAL_ERROR, _("expecting a value for value of type %s"), virConfTypeToString(VIR_CONF_STRING)); - virConfFreeValue(value); + g_clear_pointer(value, virConfFreeValue); return -1; } =20 @@ -1348,7 +1354,7 @@ virConfSetValue(virConf *conf, cur =3D g_new0(virConfEntry, 1); cur->comment =3D NULL; cur->name =3D g_strdup(setting); - cur->value =3D value; + cur->value =3D g_steal_pointer(value); if (prev) { cur->next =3D prev->next; prev->next =3D cur; @@ -1358,7 +1364,7 @@ virConfSetValue(virConf *conf, } } else { virConfFreeValue(cur->value); - cur->value =3D value; + cur->value =3D g_steal_pointer(value); } return 0; } diff --git a/src/util/virconf.h b/src/util/virconf.h index 558009b92e..e656a6a815 100644 --- a/src/util/virconf.h +++ b/src/util/virconf.h @@ -115,7 +115,7 @@ int virConfGetValueULLong(virConf *conf, =20 int virConfSetValue(virConf *conf, const char *setting, - virConfValue *value); + virConfValue **value); int virConfWalk(virConf *conf, virConfWalkCallback callback, void *opaque); --=20 2.34.1 From nobody Sat Apr 20 09:14:34 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=1642171265; cv=none; d=zohomail.com; s=zohoarc; b=Nc4XaER1WOCVAO06FuGUxht246qYozJsCURdVbCHeZM6OysDpBClUNWbr226qZ4Bh2lhiN1sl9T62WI4S1Qm5YA+t+uSLmg+t7CqV3RE2sCrVKECpo+WXlAHuXYVxNRy/TWAWfDWfnB+jX7tY5lBJLTlEzG+/MczpAaaDXQ9Uy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171265; 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=AIVGgclZZVVa0jdKLi70YDgQ7AdUr32hHS+yj/Vy4mQ=; b=Y7O30MY/uTfcXfSWMBJD/W+UJhvfESU8bm2+dp/jTLM5oCNHxnjIbyTIGMPRYgJ/w9/32ENDpqDD5HSIwiNgxfg5gtJZEvfdEV0IB3j+jUkMNrY/tpcs6ZWl2mf+tq7yKVVPi4JJsmibInQBysCPAbqsZk3/QLDrIBg35Cs//Gw= 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 1642171265626670.3541833109438; Fri, 14 Jan 2022 06:41: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-587-Dtb13_mNNvWytsJaSqOs8A-1; Fri, 14 Jan 2022 09:40:33 -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 7160E1926DA8; Fri, 14 Jan 2022 14:40:27 +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 489F42BCC1; Fri, 14 Jan 2022 14:40:27 +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 168B418033AE; Fri, 14 Jan 2022 14:40:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeD3Y029260 for ; Fri, 14 Jan 2022 09:40:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5DD627B6EE; Fri, 14 Jan 2022 14:40:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA7EB7B6EB for ; Fri, 14 Jan 2022 14:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171264; 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=AIVGgclZZVVa0jdKLi70YDgQ7AdUr32hHS+yj/Vy4mQ=; b=QlWWAHGjb74P1J0PBQnF0IJc6w9vGDwfMDEK09kc8DIhyy6T7eTdHaRbh/myTaKoym1lh4 jFKDxt1CeNKAoJPc0Qfcj2/Uqevbvw0Thv+xOQBW/Rj6IL65ehlR62McMYvh1SpmXJntTI 4wFdxvzcR5x4KlC1fHlrxWwiz3Yz85Q= X-MC-Unique: Dtb13_mNNvWytsJaSqOs8A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/11] libxl: Don't use a static buffer in xenParseXLVnuma() Date: Fri, 14 Jan 2022 15:39:50 +0100 Message-Id: <53c3b5a71ecb3c416c33e6e553913cca51469ed4.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171266407100003 Content-Type: text/plain; charset="utf-8" The xenParseXLVnuma() function is responsible for parsing 'vnuma' part of XL config and setting corresponding values in virDomainDef. While doing so it uses a static buffer which is set to data we are interested in and then parsing the buffer further (e.g. string to integer conversion, bitmap parsing, and so on). Well, the data we are interested in are already in a string (@data) which can be used directly rendering this intermediary buffer needless. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 43 ++++--------------------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 6e489f35ad..3a4e21ee0e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -394,7 +394,6 @@ xenParseXLVnuma(virConf *conf, virDomainDef *def) { int ret =3D -1; - char *tmp =3D NULL; size_t vcpus =3D 0; size_t nr_nodes =3D 0; size_t vnodeCnt =3D 0; @@ -446,19 +445,10 @@ xenParseXLVnuma(virConf *conf, data++; =20 if (*data) { - char vtoken[64]; - if (STRPREFIX(str, "pnode")) { unsigned int cellid; =20 - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu pnode '%s' t= oo long for destination"), - vnodeCnt, data); - goto cleanup; - } - - if ((virStrToLong_ui(vtoken, NULL, 10, &cellid) < = 0) || + if ((virStrToLong_ui(data, NULL, 10, &cellid) < 0)= || (cellid >=3D nr_nodes)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vnuma vnode %zu contains inv= alid pnode value '%s'"), @@ -467,27 +457,13 @@ xenParseXLVnuma(virConf *conf, } pnode =3D cellid; } else if (STRPREFIX(str, "size")) { - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu size '%s' to= o long for destination"), - vnodeCnt, data); - goto cleanup; - } - - if (virStrToLong_ull(vtoken, NULL, 10, &kbsize) < = 0) + if (virStrToLong_ull(data, NULL, 10, &kbsize) < 0) goto cleanup; =20 virDomainNumaSetNodeMemorySize(numa, vnodeCnt, (kb= size * 1024)); =20 } else if (STRPREFIX(str, "vcpus")) { - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu vcpus '%s' t= oo long for destination"), - vnodeCnt, data); - goto cleanup; - } - - if (virBitmapParse(vtoken, &cpumask, VIR_DOMAIN_CP= UMASK_LEN) < 0) + if (virBitmapParse(data, &cpumask, VIR_DOMAIN_CPUM= ASK_LEN) < 0) goto cleanup; =20 virDomainNumaSetNodeCpumask(numa, vnodeCnt, cpumas= k); @@ -498,17 +474,7 @@ xenParseXLVnuma(virConf *conf, size_t i, ndistances; unsigned int value; =20 - if (virStrcpyStatic(vtoken, data) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("vnuma vnode %zu vdistances '= %s' too long for destination"), - vnodeCnt, data); - goto cleanup; - } - - VIR_FREE(tmp); - tmp =3D g_strdup(vtoken); - - if (!(token =3D g_strsplit(tmp, ",", 0))) + if (!(token =3D g_strsplit(data, ",", 0))) goto cleanup; =20 ndistances =3D g_strv_length(token); @@ -571,7 +537,6 @@ xenParseXLVnuma(virConf *conf, cleanup: if (ret) VIR_FREE(cpu); - VIR_FREE(tmp); =20 return ret; } --=20 2.34.1 From nobody Sat Apr 20 09:14:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642171233; cv=none; d=zohomail.com; s=zohoarc; b=jMXERM88yd89UEiC05rfg5knh8IQQTfCSDlozzE2x0QEEAWCEdQFQfm4PR8pOHdWUbcppju3whuHoN++/t/+CRJ0fTNw+UACAi0D0Jl8cUUZwEd6ZZtWYC5RFcWzlzg9jTYFniTDPvsu4KFtbqZd8sEc7pEwzFh0kKSMJFR+TcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171233; 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=C8XoeUwWu+O9DyxYTPwv/yNhOeQrfG0Azeht9xrmrTI=; b=g+Huc4sKD0ZBRc13oGmaD3EVC1qzR5vr69pbC0I7KwXBeCHDeQXslMPLE7Rt/vkKTMIlWdN1HYXeP4d0B3X4kwmdcPrRLj1rYMzrlhYh7Epsb5F/PLqO7AICKRdSRH/xgqgcKbNL2nrAb3Wt7gAu1lrlH1dcXgTWDgUnrbMkR8o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 164217123342186.6466646792876; Fri, 14 Jan 2022 06:40:33 -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-607-1yMFpkSoOw-usicdNlWfUA-1; Fri, 14 Jan 2022 09:40:29 -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 2AABD84B9AA; Fri, 14 Jan 2022 14:40:23 +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 F159A84D29; Fri, 14 Jan 2022 14:40: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 B54541806D2D; Fri, 14 Jan 2022 14:40:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeEwg029277 for ; Fri, 14 Jan 2022 09:40:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 511377B6EE; Fri, 14 Jan 2022 14:40:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id B64C57B6EB for ; Fri, 14 Jan 2022 14:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171232; 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=C8XoeUwWu+O9DyxYTPwv/yNhOeQrfG0Azeht9xrmrTI=; b=jSYPnxC2xd8A69KMGUtbdvXy18aIl+xcD5ZOgZOIJCNGawXxgrps4TDulIleXOxbU2TadR 4Iwjh2ieJp9xVkOAODanNthISAruhpMuOe1sTWRvGSpcaojhWei9Qw4AfMz9nk47eP22xY TD6APvslNQySnH4DU5GVBhb2vzSOUwA= X-MC-Unique: 1yMFpkSoOw-usicdNlWfUA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/11] libxl: Allocate @libxldisk in xenParseXLDisk() on stack Date: Fri, 14 Jan 2022 15:39:51 +0100 Message-Id: <14ea278bbd7c1febc2bba84ba0e7d130ab4c9616.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642171235278100001 Content-Type: text/plain; charset="utf-8" In xenParseXLDisk() the @libxldisk variable (which is type of libxl_device_disk) is allocated on heap. But this is not necessary as nothing in the function needs that approach. Allocate the variable on the stack and drop corresponding VIR_FREE() call. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 3a4e21ee0e..f32a6cd65a 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -641,11 +641,9 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) int ret =3D -1; virConfValue *list =3D virConfGetValue(conf, "disk"); XLU_Config *xluconf; - libxl_device_disk *libxldisk; + libxl_device_disk libxldisk; virDomainDiskDef *disk =3D NULL; =20 - libxldisk =3D g_new0(libxl_device_disk, 1); - if (!(xluconf =3D xlu_cfg_init(stderr, "command line"))) goto cleanup; =20 @@ -657,23 +655,23 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) if (list->type !=3D VIR_CONF_STRING || list->str =3D=3D NULL) goto skipdisk; =20 - libxl_device_disk_init(libxldisk); + libxl_device_disk_init(&libxldisk); =20 - if (xlu_disk_parse(xluconf, 1, &disk_spec, libxldisk)) + if (xlu_disk_parse(xluconf, 1, &disk_spec, &libxldisk)) goto fail; =20 if (!(disk =3D virDomainDiskDefNew(NULL))) goto fail; =20 - if (xenParseXLDiskSrc(disk, libxldisk->pdev_path) < 0) + if (xenParseXLDiskSrc(disk, libxldisk.pdev_path) < 0) goto fail; =20 - disk->dst =3D g_strdup(libxldisk->vdev); + disk->dst =3D g_strdup(libxldisk.vdev); =20 - disk->src->readonly =3D !libxldisk->readwrite; - disk->removable =3D libxldisk->removable; + disk->src->readonly =3D !libxldisk.readwrite; + disk->removable =3D libxldisk.removable; =20 - if (libxldisk->is_cdrom) { + if (libxldisk.is_cdrom) { virDomainDiskSetDriver(disk, "qemu"); =20 virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); @@ -683,7 +681,7 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) else disk->src->format =3D VIR_STORAGE_FILE_RAW; } else { - switch (libxldisk->format) { + switch (libxldisk.format) { case LIBXL_DISK_FORMAT_QCOW: disk->src->format =3D VIR_STORAGE_FILE_QCOW; break; @@ -711,11 +709,11 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk image format not supported: %s"= ), - libxl_disk_format_to_string(libxldisk->= format)); + libxl_disk_format_to_string(libxldisk.f= ormat)); goto fail; } =20 - switch (libxldisk->backend) { + switch (libxldisk.backend) { case LIBXL_DISK_BACKEND_QDISK: case LIBXL_DISK_BACKEND_UNKNOWN: virDomainDiskSetDriver(disk, "qemu"); @@ -735,22 +733,22 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk backend not supported: %s"), - libxl_disk_backend_to_string(libxldisk-= >backend)); + libxl_disk_backend_to_string(libxldisk.= backend)); goto fail; } } =20 - if (STRPREFIX(libxldisk->vdev, "xvd") || + if (STRPREFIX(libxldisk.vdev, "xvd") || def->os.type !=3D VIR_DOMAIN_OSTYPE_HVM) disk->bus =3D VIR_DOMAIN_DISK_BUS_XEN; - else if (STRPREFIX(libxldisk->vdev, "sd")) + else if (STRPREFIX(libxldisk.vdev, "sd")) disk->bus =3D VIR_DOMAIN_DISK_BUS_SCSI; else disk->bus =3D VIR_DOMAIN_DISK_BUS_IDE; =20 VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); =20 - libxl_device_disk_dispose(libxldisk); + libxl_device_disk_dispose(&libxldisk); =20 skipdisk: list =3D list->next; @@ -761,11 +759,10 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) cleanup: virDomainDiskDefFree(disk); xlu_cfg_destroy(xluconf); - VIR_FREE(libxldisk); return ret; =20 fail: - libxl_device_disk_dispose(libxldisk); + libxl_device_disk_dispose(&libxldisk); goto cleanup; } =20 --=20 2.34.1 From nobody Sat Apr 20 09:14:34 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=1642171233; cv=none; d=zohomail.com; s=zohoarc; b=OG6+5+yPuZCn36G2+CQRPMcDBdhRSemg7glo5XoQd7JzNQuEsKpsxZytRaKhkIfnOFQnNQft+Owjh++XB4ZnXZI2ajPPBJuwyYpQAa/coBwR3+EoqgvxbvH8X8O4wS6MQdQLfDiKLi2p3tWiwNwCKnL6zndKR++zRKJhxe7uwJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171233; 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=veCBA8sKywSXuVxtQue80ndMcog+TbwjDyGeQ8n4EJY=; b=LOGAnz9ou4pz24VlJ3RNuhGZrC9DA0cgIOQ1NS8j6MWurPItkwDjJ76uL96eW6/AgaRB89bTh2+kn+QABDv49/QoCbNxHBxKrf46dgaN4Fm0tjeuo0bQD12Qo0OTmB6epNZKQtF3L4vPxY8dYQIp+2yhbeblCukslT0lWL8IgHQ= 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 1642171233453340.0380078901645; Fri, 14 Jan 2022 06:40:33 -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-526-ouBlnN7MMDSkQKsFfeNuNA-1; Fri, 14 Jan 2022 09:40:28 -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 262CF1054FA4; Fri, 14 Jan 2022 14:40:23 +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 EBF7484D1F; Fri, 14 Jan 2022 14:40: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 B514B4A705; Fri, 14 Jan 2022 14:40:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeFBc029284 for ; Fri, 14 Jan 2022 09:40:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 42BBF7B6EB; Fri, 14 Jan 2022 14:40:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id A36CA7B6F1 for ; Fri, 14 Jan 2022 14:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171232; 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=veCBA8sKywSXuVxtQue80ndMcog+TbwjDyGeQ8n4EJY=; b=Xcz75YSeqz8LqiCV48ODace+P2mMiYoaqwNLBJaovX4Fg6FDLiFdcepGqWbjGnrkoLZzM8 LExNJlydAeSFxy7x5JfRIv8v44BHRZS3hYFNxSx2kk5IL+RD8ucxRt2M6zqgaF+KUMgt+z ew6KHhwBFjHWVpkP5hoYHrAq6XDXZUg= X-MC-Unique: ouBlnN7MMDSkQKsFfeNuNA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/11] xen_xl.c: Use g_autofree more Date: Fri, 14 Jan 2022 15:39:52 +0100 Message-Id: <03544966a21979b3c8c04c10a467749a0078e32b.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642171235292100002 Content-Type: text/plain; charset="utf-8" There are few places inside src/libxl/xen_xl.c that can benefit from g_autofree. Let them use automatic memory freeing. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index f32a6cd65a..043f3c27db 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -321,10 +321,11 @@ xenParseXLSpice(virConf *conf, virDomainDef *def) { virDomainGraphicsDef *graphics =3D NULL; unsigned long port; - char *listenAddr =3D NULL; int val; =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { + g_autofree char *listenAddr =3D NULL; + if (xenConfigGetBool(conf, "spice", &val, 0) < 0) return -1; =20 @@ -335,7 +336,6 @@ xenParseXLSpice(virConf *conf, virDomainDef *def) goto cleanup; if (virDomainGraphicsListenAppendAddress(graphics, listenAddr)= < 0) goto cleanup; - VIR_FREE(listenAddr); =20 if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0) goto cleanup; @@ -384,7 +384,6 @@ xenParseXLSpice(virConf *conf, virDomainDef *def) return 0; =20 cleanup: - VIR_FREE(listenAddr); virDomainGraphicsDefFree(graphics); return -1; } @@ -575,7 +574,6 @@ xenParseXLXenbusLimits(virConf *conf, virDomainDef *def) static int xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) { - char *tmpstr =3D NULL; int ret =3D -1; =20 /* A NULL source is valid, e.g. an empty CDROM */ @@ -583,6 +581,8 @@ xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) return 0; =20 if (STRPREFIX(srcstr, "rbd:")) { + g_autofree char *tmpstr =3D NULL; + if (!(tmpstr =3D virStringReplace(srcstr, "\\\\", "\\"))) goto cleanup; =20 @@ -596,7 +596,6 @@ xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) } =20 cleanup: - VIR_FREE(tmpstr); return ret; } =20 @@ -952,13 +951,13 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) { virConfValue *list =3D virConfGetValue(conf, "channel"); virDomainChrDef *channel =3D NULL; - char *name =3D NULL; - char *path =3D NULL; =20 if (list && list->type =3D=3D VIR_CONF_LIST) { list =3D list->list; while (list) { g_autofree char *type =3D NULL; + g_autofree char *name =3D NULL; + g_autofree char *path =3D NULL; char *key; =20 if ((list->type !=3D VIR_CONF_STRING) || (list->str =3D=3D NUL= L)) @@ -1003,7 +1002,6 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) channel->source->data.nix.path =3D g_steal_pointer(&path); } else if (STRPREFIX(type, "pty")) { channel->source->type =3D VIR_DOMAIN_CHR_TYPE_PTY; - VIR_FREE(path); } else { goto cleanup; } @@ -1023,8 +1021,6 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) =20 cleanup: virDomainChrDefFree(channel); - VIR_FREE(path); - VIR_FREE(name); return -1; } =20 @@ -1382,7 +1378,6 @@ xenFormatXLVnuma(virConfValue *list, list->list =3D numaVnode; ret =3D 0; =20 - VIR_FREE(nodeVcpus); return ret; } =20 --=20 2.34.1 From nobody Sat Apr 20 09:14:34 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=1642171263; cv=none; d=zohomail.com; s=zohoarc; b=a4rcoFe1v8XxSWVR/hD2v1LAJ0lH4Zd4K1msUjQXpSR0juseuPyJSZI8gzP8ciQRiF9XmlqyzmWy/14jXWcuXlPD14/P2jc9Qmr9d7OjORzgamgL/X4yX5tWcJkF7d8PL5cTswXP32bkOF8E4r+mBHs4rr4aC73gsSVxmUcMCu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171263; 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=3en6brDih5O4rKQ3iNUN4vZNPXO3Qh/+1DRjplSgEaw=; b=T+csIMGzOYyDqg69X8/v+qrhhxA/Et5cPloTkKn2wn2EC23dKWr/aRx1MFN843Un0rYA5yE5osj8QWXyHItS5mo6KuB8bsb1UQAocYOi0i6NEjh5hsQJR/6u+bWz+0MCwS4seaN1wH7cKq09pjA4vnZQDCBl5zu9gUFbNF1KBFM= 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 1642171263669894.3670998927727; Fri, 14 Jan 2022 06:41:03 -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-642-_0mcESMTN2yDvZGOkSWsJw-1; Fri, 14 Jan 2022 09:40:31 -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 EFB92760CA; Fri, 14 Jan 2022 14:40:25 +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 C862784D22; Fri, 14 Jan 2022 14:40:25 +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 95C321805302; Fri, 14 Jan 2022 14:40:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeGK6029301 for ; Fri, 14 Jan 2022 09:40:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 380067B6F2; Fri, 14 Jan 2022 14:40:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DCE97B6F1 for ; Fri, 14 Jan 2022 14:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171262; 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=3en6brDih5O4rKQ3iNUN4vZNPXO3Qh/+1DRjplSgEaw=; b=WlGsumDVO1XMS/7xwVZo3XoCHscNVrULXVmFOPNknw+KUg/lDdJMVa3vI5CxCfl/KizA2k Fwg236y+szEwBZBSHz6DLgMoYrvFkean2siodGJ8Vgjxvnx07ztg0hpSJHh4W/lrOsaYY0 a2oJ4pkMmlmf6RuIvrX/9rfO9sFs1m4= X-MC-Unique: _0mcESMTN2yDvZGOkSWsJw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/11] xen_xl.c: Use g_autoptr() for virCPUDef Date: Fri, 14 Jan 2022 15:39:53 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642171265882100001 Content-Type: text/plain; charset="utf-8" In xenParseXLVnuma() the @cpu variable is freed explicitly. However, when switched to g_autoptr(virCPUDef) the explicit call can be removed. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 043f3c27db..25bf1f7893 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -396,7 +396,7 @@ xenParseXLVnuma(virConf *conf, size_t vcpus =3D 0; size_t nr_nodes =3D 0; size_t vnodeCnt =3D 0; - virCPUDef *cpu =3D NULL; + g_autoptr(virCPUDef) cpu =3D NULL; virConfValue *list; virConfValue *vnode; virDomainNuma *numa; @@ -529,14 +529,11 @@ xenParseXLVnuma(virConf *conf, } =20 cpu->type =3D VIR_CPU_TYPE_GUEST; - def->cpu =3D cpu; + def->cpu =3D g_steal_pointer(&cpu); =20 ret =3D 0; =20 cleanup: - if (ret) - VIR_FREE(cpu); - return ret; } =20 --=20 2.34.1 From nobody Sat Apr 20 09:14:34 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=1642171235; cv=none; d=zohomail.com; s=zohoarc; b=lscWuH2bl38RBBNQNkueHYGwYuJLf26z6k79L7MlCt58K9WzbnqNgYcmQ66+IeqJHNQhAB9xpF6IjrbI0EDZDgwnTozgaNJGB6BIIJCuv4xzN9mUAlycWuyMx09415oSdof+6y383aqNSVIHprCqJpd013Z0ghnQU2SkVmZda5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171235; 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=PLiIkrucJUA1WnF+tyMbVFqnHpMqP38pdd3opWZV97c=; b=iB7C9R0QchOmtytDI9uuqG20l2jUsunU/8sqtkozumkkHb0dGzg5UEJZhAyJ6XZeobZm5l6qWoU3UsszwBkvPGaUjwMN/0Qp1P+UJsewwQw4peLidyslun9FBBtFk7Ytz1NHXUbw3Nrz2a5lj1heGXxrQ0ICKe5LgxTZC8qAHCg= 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 16421712355691020.4246388532346; Fri, 14 Jan 2022 06:40:35 -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-660-elrRgQtfPsCWgNh2nepX_Q-1; Fri, 14 Jan 2022 09:40:31 -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 F02001926DB1; Fri, 14 Jan 2022 14:40:25 +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 C83C584D1C; Fri, 14 Jan 2022 14:40:25 +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 939A71806D2F; Fri, 14 Jan 2022 14:40:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeHsN029315 for ; Fri, 14 Jan 2022 09:40:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2B06E7B6F2; Fri, 14 Jan 2022 14:40:17 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 955347B6F1 for ; Fri, 14 Jan 2022 14:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171234; 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=PLiIkrucJUA1WnF+tyMbVFqnHpMqP38pdd3opWZV97c=; b=FvN7QT+c1FQrH9GUh5IuBkbKUDpSUh/OTxD05djJiw0jp8Om7mxXOtGpUJ7YUNNgN5ghzs FPAXLnJxGalyF/DVW26QHjaSKM/EMGgkAHFF1wFxEl1+l29uDP81eJr/nq3022oVsTonO3 ibJYulK3NqQBYxG+Nr8CQ2vvlovRSG4= X-MC-Unique: elrRgQtfPsCWgNh2nepX_Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/11] libxl: Remove needless labels Date: Fri, 14 Jan 2022 15:39:54 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642171236834100005 Content-Type: text/plain; charset="utf-8" After previous cleanups some labels are needless: they contain nothing but a return statement. Drop such labels and return directly. Signed-off-by: Michal Privoznik --- src/libxl/xen_common.c | 7 ++-- src/libxl/xen_xl.c | 80 ++++++++++++++---------------------------- src/libxl/xen_xm.c | 7 ++-- 3 files changed, 31 insertions(+), 63 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 2d363ac2fb..c3fa98b71d 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -2313,17 +2313,14 @@ xenFormatVif(virConf *conf, for (i =3D 0; i < def->nnets; i++) { if (xenFormatNet(conn, netVal, def->nets[i], hvm, vif_typename) < 0) - goto cleanup; + return -1; } =20 if (netVal->list !=3D NULL && virConfSetValue(conf, "vif", &netVal) < 0) - goto cleanup; + return -1; =20 return 0; - - cleanup: - return -1; } =20 =20 diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 25bf1f7893..e3a87890af 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -392,7 +392,6 @@ static int xenParseXLVnuma(virConf *conf, virDomainDef *def) { - int ret =3D -1; size_t vcpus =3D 0; size_t nr_nodes =3D 0; size_t vnodeCnt =3D 0; @@ -416,7 +415,7 @@ xenParseXLVnuma(virConf *conf, } =20 if (!virDomainNumaSetNodeCount(numa, nr_nodes)) - goto cleanup; + return -1; =20 cpu =3D virCPUDefNew(); =20 @@ -439,7 +438,7 @@ xenParseXLVnuma(virConf *conf, virReportError(VIR_ERR_INTERNAL_ERROR, _("vnuma vnode invalid format '%s'"), str); - goto cleanup; + return -1; } data++; =20 @@ -452,18 +451,18 @@ xenParseXLVnuma(virConf *conf, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vnuma vnode %zu contains inv= alid pnode value '%s'"), vnodeCnt, data); - goto cleanup; + return -1; } pnode =3D cellid; } else if (STRPREFIX(str, "size")) { if (virStrToLong_ull(data, NULL, 10, &kbsize) < 0) - goto cleanup; + return -1; =20 virDomainNumaSetNodeMemorySize(numa, vnodeCnt, (kb= size * 1024)); =20 } else if (STRPREFIX(str, "vcpus")) { if (virBitmapParse(data, &cpumask, VIR_DOMAIN_CPUM= ASK_LEN) < 0) - goto cleanup; + return -1; =20 virDomainNumaSetNodeCpumask(numa, vnodeCnt, cpumas= k); vcpus +=3D virBitmapCountBits(cpumask); @@ -474,7 +473,7 @@ xenParseXLVnuma(virConf *conf, unsigned int value; =20 if (!(token =3D g_strsplit(data, ",", 0))) - goto cleanup; + return -1; =20 ndistances =3D g_strv_length(token); =20 @@ -482,23 +481,23 @@ xenParseXLVnuma(virConf *conf, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vnuma pnode %d configured '%s' (= count %zu) doesn't fit the number of specified vnodes %zu"), pnode, str, ndistances, nr_nodes); - goto cleanup; + return -1; } =20 if (virDomainNumaSetNodeDistanceCount(numa, vnodeC= nt, ndistances) !=3D ndistances) - goto cleanup; + return -1; =20 for (i =3D 0; i < ndistances; i++) { if ((virStrToLong_ui(token[i], NULL, 10, &valu= e) < 0) || (virDomainNumaSetNodeDistance(numa, vnodeC= nt, i, value) !=3D value)) - goto cleanup; + return -1; } =20 } else { virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid vnuma configuration for = vnode %zu"), vnodeCnt); - goto cleanup; + return -1; } } vnode =3D vnode->next; @@ -511,7 +510,7 @@ xenParseXLVnuma(virConf *conf, virReportError(VIR_ERR_CONF_SYNTAX, _("Incomplete vnuma configuration for vnode %zu= "), vnodeCnt); - goto cleanup; + return -1; } =20 list =3D list->next; @@ -525,16 +524,13 @@ xenParseXLVnuma(virConf *conf, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vnuma configuration contains %zu vcpus, which is= greater than %zu maxvcpus"), vcpus, def->maxvcpus); - goto cleanup; + return -1; } =20 cpu->type =3D VIR_CPU_TYPE_GUEST; def->cpu =3D g_steal_pointer(&cpu); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -571,8 +567,6 @@ xenParseXLXenbusLimits(virConf *conf, virDomainDef *def) static int xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) { - int ret =3D -1; - /* A NULL source is valid, e.g. an empty CDROM */ if (srcstr =3D=3D NULL) return 0; @@ -581,19 +575,16 @@ xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcst= r) g_autofree char *tmpstr =3D NULL; =20 if (!(tmpstr =3D virStringReplace(srcstr, "\\\\", "\\"))) - goto cleanup; + return -1; =20 virDomainDiskSetType(disk, VIR_STORAGE_TYPE_NETWORK); disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_RBD; - ret =3D virStorageSourceParseRBDColonString(tmpstr, disk->src); - } else { - virDomainDiskSetSource(disk, srcstr); - - ret =3D 0; + return virStorageSourceParseRBDColonString(tmpstr, disk->src); } =20 - cleanup: - return ret; + virDomainDiskSetSource(disk, srcstr); + + return 0; } =20 =20 @@ -1398,7 +1389,7 @@ xenFormatXLDomainVnuma(virConf *conf, nr_nodes =3D virDomainNumaGetNodeCount(numa); for (i =3D 0; i < nr_nodes; i++) { if (xenFormatXLVnuma(vnumaVal, numa, i, nr_nodes) < 0) - goto cleanup; + return -1; } =20 if (vnumaVal->list !=3D NULL && @@ -1406,9 +1397,6 @@ xenFormatXLDomainVnuma(virConf *conf, return -1; =20 return 0; - - cleanup: - return -1; } =20 static int @@ -1645,7 +1633,7 @@ xenFormatXLDomainDisks(virConf *conf, virDomainDef *d= ef) continue; =20 if (xenFormatXLDisk(diskVal, def->disks[i]) < 0) - goto cleanup; + return -1; } =20 if (diskVal->list !=3D NULL && @@ -1653,9 +1641,6 @@ xenFormatXLDomainDisks(virConf *conf, virDomainDef *d= ef) return -1; =20 return 0; - - cleanup: - return -1; } =20 =20 @@ -1762,7 +1747,7 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *def) for (i =3D 0; i < def->ninputs; i++) { if (def->inputs[i]->bus =3D=3D VIR_DOMAIN_INPUT_BUS_USB) { if (xenConfigSetInt(conf, "usb", 1) < 0) - goto error; + return -1; =20 switch (def->inputs[i]->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: @@ -1794,17 +1779,15 @@ xenFormatXLInputDevs(virConf *conf, virDomainDef *d= ef) /* for compatibility with Xen <=3D 4.2, use old syntax when * only one device present */ if (xenConfigSetString(conf, "usbdevice", usbdevices->list= ->str) < 0) - goto error; + return -1; } else { if (virConfSetValue(conf, "usbdevice", &usbdevices) < 0) - goto error; + return -1; } } } =20 return 0; - error: - return -1; } =20 static int @@ -1847,7 +1830,7 @@ xenFormatXLUSBController(virConf *conf, break; =20 default: - goto error; + return -1; } } =20 @@ -1873,9 +1856,6 @@ xenFormatXLUSBController(virConf *conf, return -1; =20 return 0; - - error: - return -1; } =20 =20 @@ -1993,17 +1973,14 @@ xenFormatXLDomainChannels(virConf *conf, virDomainD= ef *def) continue; =20 if (xenFormatXLChannel(channelVal, def->channels[i]) < 0) - goto cleanup; + return -1; } =20 if (channelVal->list !=3D NULL && virConfSetValue(conf, "channel", &channelVal) < 0) - goto cleanup; + return -1; =20 return 0; - - cleanup: - return -1; } =20 static int @@ -2043,12 +2020,9 @@ xenFormatXLDomainNamespaceData(virConf *conf, virDom= ainDef *def) =20 if (args->list !=3D NULL && virConfSetValue(conf, "device_model_args", &args) < 0) - goto error; + return -1; =20 return 0; - - error: - return -1; } =20 virConf * diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index f20307430c..2e636d874e 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -353,17 +353,14 @@ xenFormatXMDisks(virConf *conf, virDomainDef *def) continue; =20 if (xenFormatXMDisk(diskVal, def->disks[i]) < 0) - goto cleanup; + return -1; } =20 if (diskVal->list !=3D NULL && virConfSetValue(conf, "disk", &diskVal) < 0) - goto cleanup; + return -1; =20 return 0; - - cleanup: - return -1; } =20 =20 --=20 2.34.1 From nobody Sat Apr 20 09:14:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642171245; cv=none; d=zohomail.com; s=zohoarc; b=MIf9j0I7nMecwZl3yMw8SYn1sRtutpYxYpXSp+CaPy0NzE6moa9wCslVerjELI8tYA+sWKAcFzuQSZ/2M4YKA5yckxhnZzqeyfaRQ0X7T2Pd1NCsBjFywOY91fPGbm4JDDJFus8I2pjVVJ7iRu9eApPstgPkMbo6SRcfacBRt9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171245; 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=G0MQ0MJZWpl4aLaSVO7sAfEaT43i5Oy3hrfdtELlu3U=; b=mmAD1ltZgQoUwwpunRCK98InAKbDIlUh3sTC9xVamSiOaFSqQc00R8Nyes1PsRsJ3k/mSwiwVkYFarLb1MI3CtN3/6Xslt+/0hwKhYZh+PYIcCjEG9rfwZfnBfL9Ldg0KrLN50JWgeMnaT5QQH9LG4q44Ni0/vyUuo7IBfDC3cs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642171245736306.4041163063382; Fri, 14 Jan 2022 06:40:45 -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-175-ojgDfz0CNgGP797ecFWp2A-1; Fri, 14 Jan 2022 09:40:36 -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 16C4184B9A9; Fri, 14 Jan 2022 14:40:29 +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 EA666106C07F; Fri, 14 Jan 2022 14:40:28 +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 B618C4A70C; Fri, 14 Jan 2022 14:40:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20EEeI9K029326 for ; Fri, 14 Jan 2022 09:40:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 07EDB7B6F1; Fri, 14 Jan 2022 14:40:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B1E07B6F4 for ; Fri, 14 Jan 2022 14:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171244; 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=G0MQ0MJZWpl4aLaSVO7sAfEaT43i5Oy3hrfdtELlu3U=; b=LatcAZRheMT0JX4sp0D7VJRvj7R64BJX9zjDe+XZiBomgvJqPYZpnEmCftiv5q7ifB0nr+ 0xpZM/H12kqTU/fDxy19bhguPMWyDe41I7IWLxefGW5b14Bay39mV3ysWE4q4zW4naVApN 2WduuU1UoJGTMXgTXCrn4OObhxFWMvg= X-MC-Unique: ojgDfz0CNgGP797ecFWp2A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/11] virsh: Remove needless labels Date: Fri, 14 Jan 2022 15:39:55 +0100 Message-Id: <6a4084285d2b446e39f10ab139e1c92991a3d125.1642171139.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) X-ZM-MESSAGEID: 1642171246964100001 Content-Type: text/plain; charset="utf-8" There are few places where a cleanup label contains nothing but a return statement. Drop such labels and return directly. Signed-off-by: Michal Privoznik --- tools/virsh-host.c | 20 ++++++-------------- tools/vsh.c | 11 ++++------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 5ee3834de2..2e3cbc39b6 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1195,7 +1195,6 @@ static bool cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) { const char *from =3D NULL; - bool ret =3D false; int result; g_auto(GStrv) cpus =3D NULL; unsigned int flags =3D 0; @@ -1219,7 +1218,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) case VIR_CPU_COMPARE_INCOMPATIBLE: vshPrint(ctl, _("CPU described in %s is incompatible with host CPU= \n"), from); - goto cleanup; + return false; break; =20 case VIR_CPU_COMPARE_IDENTICAL: @@ -1235,13 +1234,10 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) case VIR_CPU_COMPARE_ERROR: default: vshError(ctl, _("Failed to compare host CPU with %s"), from); - goto cleanup; + return false; } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -1615,7 +1611,6 @@ cmdHypervisorCPUCompare(vshControl *ctl, const char *emulator =3D NULL; const char *arch =3D NULL; const char *machine =3D NULL; - bool ret =3D false; int result; g_auto(GStrv) cpus =3D NULL; unsigned int flags =3D 0; @@ -1646,7 +1641,7 @@ cmdHypervisorCPUCompare(vshControl *ctl, _("CPU described in %s is incompatible with the CPU provi= ded " "by hypervisor on the host\n"), from); - goto cleanup; + return false; break; =20 case VIR_CPU_COMPARE_IDENTICAL: @@ -1666,13 +1661,10 @@ cmdHypervisorCPUCompare(vshControl *ctl, case VIR_CPU_COMPARE_ERROR: default: vshError(ctl, _("Failed to compare hypervisor CPU with %s"), from); - goto cleanup; + return false; } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 diff --git a/tools/vsh.c b/tools/vsh.c index e3e27a0ba6..c0098054e0 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3360,7 +3360,6 @@ const vshCmdInfo info_complete[] =3D { bool cmdComplete(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; const vshClientHooks *hooks =3D ctl->hooks; int stdin_fileno =3D STDIN_FILENO; const char *arg =3D ""; @@ -3370,7 +3369,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (vshCommandOptStringQuiet(ctl, cmd, "string", &arg) <=3D 0) - goto cleanup; + return false; =20 /* This command is flagged VSH_CMD_FLAG_NOCONNECT because we * need to prevent auth hooks reading any input. Therefore, we @@ -3378,7 +3377,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) VIR_FORCE_CLOSE(stdin_fileno); =20 if (!(hooks && hooks->connHandler && hooks->connHandler(ctl))) - goto cleanup; + return false; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { if (virBufferUse(&buf) !=3D 0) @@ -3397,7 +3396,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) rl_point =3D strlen(rl_line_buffer); =20 if (!(matches =3D vshReadlineCompletion(arg, 0, 0))) - goto cleanup; + return false; =20 for (iter =3D matches; *iter; iter++) { if (iter =3D=3D matches && matches[1]) @@ -3405,9 +3404,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) printf("%s\n", *iter); } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 =20 --=20 2.34.1