From nobody Sun Feb 8 18:43:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612359288; cv=none; d=zohomail.com; s=zohoarc; b=Y2EdHqMbXaL2Eu3yYdAHeZED/GAevx287ZRh5QavMjBlE7JZWyp+MCszEGxriLhti32fhJSUgb+GIOeDD7ps+RCywozlNcD3s73ISuZfgEAKpfdGe7E7/M70hL5+Hje0eGJ+/QWGF1siasc/wyq+6maMHjM70m3tW142FVKpU74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612359288; 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=nUHF4+bozopR7nWFt89tXTeEhKPJPAJX2d76afGJrP0=; b=T8YMsftqwWHV4sjGDRPBTWvBrcRk3FC0NK3uAQGQJrqsZaGi5L3UJP7hUakq9nn9MAT6rcnxbYXJcSWMMbFszmf6cG5Wbk1xbpoDLGoHpd9pyMMCSjQHJMeB5FOYryr/tfLVA5gGDYwXYVXMiY2NHjdh1DBX+TYu3snUbrng2FU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612359288286899.4299505344375; Wed, 3 Feb 2021 05:34:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-358-9P3eWbgbNtSGECHTPXQSaQ-1; Wed, 03 Feb 2021 08:34:45 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB97BDF8A7; Wed, 3 Feb 2021 13:34:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7958750EDE; Wed, 3 Feb 2021 13:34:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3BAAE18095C9; Wed, 3 Feb 2021 13:34:36 +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 113DYYhv014054 for ; Wed, 3 Feb 2021 08:34:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 36BE62CFCE; Wed, 3 Feb 2021 13:34:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A40C5884C for ; Wed, 3 Feb 2021 13:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612359287; 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=nUHF4+bozopR7nWFt89tXTeEhKPJPAJX2d76afGJrP0=; b=c5Wq7kMDIwy/VIczA8FQk+9CSk77niY0OsZh58dxTIOBnXe3I1yf+ZeqEOuKP4QHhC3pyN A9CWjvnOWrXNoaDCunxzyGAHNb2G8i64T4vm8jGfrj96nAxAB+Yrv+sHoujmCqlBdF+j2c Cg/3kGLG8/t7013q2E9D4jw8lXsVt0A= X-MC-Unique: 9P3eWbgbNtSGECHTPXQSaQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] virLockManagerSanlockAddLease: Refactor cleanup Date: Wed, 3 Feb 2021 14:34:22 +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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_autofree and remove the 'cleanup' section and 'ret' variable. Signed-off-by: Peter Krempa --- src/locking/lock_driver_sanlock.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index 9c38a1d2f6..77c8d9542b 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -528,12 +528,11 @@ static int virLockManagerSanlockAddLease(virLockManag= erPtr lock, bool shared) { virLockManagerSanlockPrivatePtr priv =3D lock->privateData; - int ret =3D -1; - struct sanlk_resource *res =3D NULL; + g_autofree struct sanlk_resource *res =3D NULL; size_t i; if (VIR_ALLOC_VAR(res, struct sanlk_disk, 1) < 0) - goto cleanup; + return -1; res->flags =3D shared ? SANLK_RES_SHARED : 0; res->num_disks =3D 1; @@ -541,7 +540,7 @@ static int virLockManagerSanlockAddLease(virLockManager= Ptr lock, virReportError(VIR_ERR_INTERNAL_ERROR, _("Resource name '%s' exceeds %d characters"), name, SANLK_NAME_LEN); - goto cleanup; + return -1; } for (i =3D 0; i < nparams; i++) { @@ -550,7 +549,7 @@ static int virLockManagerSanlockAddLease(virLockManager= Ptr lock, virReportError(VIR_ERR_INTERNAL_ERROR, _("Lease path '%s' exceeds %d characters"), params[i].value.str, SANLK_PATH_LEN); - goto cleanup; + return -1; } } else if (STREQ(params[i].key, "offset")) { res->disks[0].offset =3D params[i].value.ul; @@ -559,20 +558,15 @@ static int virLockManagerSanlockAddLease(virLockManag= erPtr lock, virReportError(VIR_ERR_INTERNAL_ERROR, _("Resource lockspace '%s' exceeds %d chara= cters"), params[i].value.str, SANLK_NAME_LEN); - goto cleanup; + return -1; } } } - priv->res_args[priv->res_count] =3D res; + priv->res_args[priv->res_count] =3D g_steal_pointer(&res); priv->res_count++; - ret =3D 0; - - cleanup: - if (ret =3D=3D -1) - VIR_FREE(res); - return ret; + return 0; } --=20 2.29.2