From nobody Sat Feb 7 12:40:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630784314; cv=none; d=zohomail.com; s=zohoarc; b=Uv39t127FdpFtV1nws7SSgNyQGeQiu3YqbwHwDV/+zqScH8tKqnwb3jXdPuPK1+6vc0CxSavCVsrdMMRq8e8dED03PAMikeJNCPyPhfq/8CI4fCEp1fRw0/AZbbZS9xxLHzkcK6hPbLNGwls/n1Dxb5SS18//VTihS2LmnzW/do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630784314; 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=QyRp5Ah5A4CA5inW9qKSYy4TQwLx/BATfAe8eXGIrjg=; b=XPicbKfnzwfjozx2/JWc40eUiwky6U61Mz9b1bo+OwdI9N4RvnB0lfEPV1ENVt9ytJsXB4xXWXm6uVgHe6fJHKofr1G6ShaXFk9p2Wz5Bv/s9zbdk9jR+U7IzAeGtq6iGnL6QPBCscqyjO38410rdKIsWL/TF1mOGT+aq/s0hmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630784314100743.7138583309671; Sat, 4 Sep 2021 12:38:34 -0700 (PDT) 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-575-69rOKS10P-S7NXkmQcY6vg-1; Sat, 04 Sep 2021 15:38:31 -0400 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 AC84F824FAD; Sat, 4 Sep 2021 19:38:26 +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 8FD8C1000320; Sat, 4 Sep 2021 19:38:26 +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 509FE44A61; Sat, 4 Sep 2021 19:38:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 184JZ2al002564 for ; Sat, 4 Sep 2021 15:35:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id E31C2781ED; Sat, 4 Sep 2021 19:35:02 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E81977718 for ; Sat, 4 Sep 2021 19:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630784313; 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=QyRp5Ah5A4CA5inW9qKSYy4TQwLx/BATfAe8eXGIrjg=; b=IIMkqhmmRdHSZC29VBkfd6SdHa7FzM44x6vRb0rfIexQDunXTOfx4s1iO7SNBVI7t+iN/l gOdAXQajwyAFJZRMth989DW2Gh2x/ZR+cXSLOpwaftEnu+LKhkDH5OxdTB0+3t7+6K4SPK m1/kWIOg8gXQtkThSNXayffMn61+I+U= X-MC-Unique: 69rOKS10P-S7NXkmQcY6vg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/6] tests: esxutils: refactor testParseDatastorePath Date: Sat, 4 Sep 2021 21:34:47 +0200 Message-Id: <011f2e700583ded58ee965637bfecfa802d64205.1630784040.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630784316066100001 Reduce variable scope to match their lifetime, use g_auto and remove now pointless labels in favor of direct returns. Signed-off-by: J=C3=A1n Tomko --- tests/esxutilstest.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c index 2e2020006e..bfb35fa356 100644 --- a/tests/esxutilstest.c +++ b/tests/esxutilstest.c @@ -35,21 +35,17 @@ static struct testPath paths[] =3D { static int testParseDatastorePath(const void *data G_GNUC_UNUSED) { - int result =3D 0; size_t i; - char *datastoreName =3D NULL; - char *directoryName =3D NULL; - char *directoryAndFileName =3D NULL; =20 for (i =3D 0; i < G_N_ELEMENTS(paths); ++i) { - VIR_FREE(datastoreName); - VIR_FREE(directoryName); - VIR_FREE(directoryAndFileName); + g_autofree char *datastoreName =3D NULL; + g_autofree char *directoryName =3D NULL; + g_autofree char *directoryAndFileName =3D NULL; =20 if (esxUtil_ParseDatastorePath (paths[i].datastorePath, &datastoreName, &directoryName, &directoryAndFileName) !=3D paths[i].result) { - goto failure; + return -1; } =20 if (paths[i].result < 0) @@ -57,32 +53,22 @@ testParseDatastorePath(const void *data G_GNUC_UNUSED) =20 if (STRNEQ(paths[i].datastoreName, datastoreName)) { virTestDifference(stderr, paths[i].datastoreName, datastoreNam= e); - goto failure; + return -1; } =20 if (STRNEQ(paths[i].directoryName, directoryName)) { virTestDifference(stderr, paths[i].directoryName, directoryNam= e); - goto failure; + return -1; } =20 if (STRNEQ(paths[i].directoryAndFileName, directoryAndFileName)) { virTestDifference(stderr, paths[i].directoryAndFileName, directoryAndFileName); - goto failure; + return -1; } } =20 - cleanup: - VIR_FREE(datastoreName); - VIR_FREE(directoryName); - VIR_FREE(directoryAndFileName); - - return result; - - failure: - result =3D -1; - - goto cleanup; + return 0; } =20 =20 --=20 2.31.1