From nobody Sun Feb 8 19:59:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1578348003; cv=none; d=zohomail.com; s=zohoarc; b=jNTOhQPi6bb/ULSzp7rzxnMjETsrvQ8vyaDg+knTLD9QGN/euv808z+xWpD9auKE28a305PO25vqOKKP3+HCsWPkE1uMvjA+a2bYcmySWLpjyzbSnmms4L60K5VqM848T4AfqRCgKAsxXXmy1j9njcb3b4B4EjqqY9avYodHSu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578348003; h=Content-Type:Content-Transfer-Encoding:Cc: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=yaPORczuOGqWnt0sUeoLAgxxlSxGCbBhCIHobVpS3eA=; b=bIjP/xeEbEMbQK39OhYY1ZpyOE5rVqPfoCjkGhHsfQKui1DfOcckF9z63dONScPbhRbOLNPJGKVDJuGn6S+oekLRIdu3JYMCe6LJkvfkCEGLNY7JeTXSD1zp0TmZLoEVSg+R1gj0HOiuXdPVFQslAtWCBMJptdFkte5p2Vyt5ig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578348003293481.7464792689467; Mon, 6 Jan 2020 14:00:03 -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-192-32bqgAA5OV-AgLUN4i0oNQ-1; Mon, 06 Jan 2020 16:59:24 -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 11CD8801E7E; Mon, 6 Jan 2020 21:59:10 +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 D8C0F1A8E2; Mon, 6 Jan 2020 21:59:09 +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 94F0A18034FF; Mon, 6 Jan 2020 21:59:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006Lwepu007434 for ; Mon, 6 Jan 2020 16:58:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id F0A48F9AB6; Mon, 6 Jan 2020 21:58:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB66B108BDA for ; Mon, 6 Jan 2020 21:58:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6B3580D959 for ; Mon, 6 Jan 2020 21:58:39 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-IfSvcJrEMjGAuQKrlBQmpw-1; Mon, 06 Jan 2020 16:58:38 -0500 Received: by mail-qk1-f178.google.com with SMTP id w127so40878966qkb.11 for ; Mon, 06 Jan 2020 13:58:37 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:655b:9e1c:e865:3705:e1df]) by smtp.gmail.com with ESMTPSA id x34sm23898440qtd.20.2020.01.06.13.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 13:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578348002; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=yaPORczuOGqWnt0sUeoLAgxxlSxGCbBhCIHobVpS3eA=; b=MF/ZY1q+MK/q7ciPl2MXPy6rUsPl6FcHpIrerBHROcYuqHhFY+9uK9cU2IsUIAc0zR6EEV VyMqwOrO0NKisIafYYhwXjzrnQ6+fS0uZgK45tM3ilHGKP6Hm1Vud8EfVS69AMnxhFmm+K 2J6wTrU5Ev60qU/u3xykdzyAID47/w4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0M/ZAh/r+EGl6Hz2TJ1+qsh+NnQtkPaz4uXcMjkLy54=; b=SKzyfCOd5LdprrheBt1ZVrbgzedo5oR9wQlgRNW505+SV6hyjsQbe1zjejYDOcVSik OACsOCSOIR4P+lgPTeTuLu5yc71KvukNkBl5gJsb3DdgN5VstTNz/k7GeXUv+27D+ETg /3c0646LbN0WnFJdRahptXKrORF0Wey2reGW6tMThmfzIptKvnWMJABg+a8v4Yj0uThL 1UQAYDuGmiN+tF7jF3TiKmRQFDJrTKpskVbFD3TsG/+WXo+SPtX3N2o8GbQsLfiIT6TE XLTLawMXwdpjQz4Bu5Fpq1Xq0y/O/lx2WUEa26PBjYpbzLz+p46dUiD3IedeL5GC9uTh ehOQ== X-Gm-Message-State: APjAAAUO/BE2HSfLXUW8so1JecRALQvyd/vl9CCZEOeuh4w6Dhw8mDUe qFFgYO3ksdadLeWqTDf2h0KKsII/ X-Google-Smtp-Source: APXvYqy5QCTM1ygDpB3pEkRSU0e7R3xQ4TNl1JlUFqweqyTniakpf/qQFtm1ofnUoNqCjgTWrpN/fw== X-Received: by 2002:a05:620a:5ae:: with SMTP id q14mr87155512qkq.437.1578347917395; Mon, 06 Jan 2020 13:58:37 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 18:57:50 -0300 Message-Id: <20200106215750.361615-27-danielhb413@gmail.com> In-Reply-To: <20200106215750.361615-1-danielhb413@gmail.com> References: <20200106215750.361615-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: IfSvcJrEMjGAuQKrlBQmpw-1 X-MC-Unique: 32bqgAA5OV-AgLUN4i0oNQ-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 006Lwepu007434 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH v1 26/26] examples: remove unneeded labels 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 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel Henrique Barboza --- examples/c/misc/hellolibvirt.c | 28 +++++++++------------------- examples/c/misc/openauth.c | 22 ++++++---------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/examples/c/misc/hellolibvirt.c b/examples/c/misc/hellolibvirt.c index bfb12846e6..a598e01be2 100644 --- a/examples/c/misc/hellolibvirt.c +++ b/examples/c/misc/hellolibvirt.c @@ -10,7 +10,6 @@ static int showHypervisorInfo(virConnectPtr conn) { - int ret =3D 0; unsigned long hvVer, major, minor, release; const char *hvType; =20 @@ -20,17 +19,15 @@ showHypervisorInfo(virConnectPtr conn) * hypervisor, so check what it returns. */ hvType =3D virConnectGetType(conn); if (!hvType) { - ret =3D 1; printf("Failed to get hypervisor type: %s\n", virGetLastErrorMessage()); - goto out; + return 1; } =20 if (0 !=3D virConnectGetVersion(conn, &hvVer)) { - ret =3D 1; printf("Failed to get hypervisor version: %s\n", virGetLastErrorMessage()); - goto out; + return 1; } =20 major =3D hvVer / 1000000; @@ -44,15 +41,14 @@ showHypervisorInfo(virConnectPtr conn) minor, release); =20 - out: - return ret; + return 0; } =20 =20 static int showDomains(virConnectPtr conn) { - int ret =3D 0, numNames, numInactiveDomains, numActiveDomains; + int numNames, numInactiveDomains, numActiveDomains; ssize_t i; int flags =3D VIR_CONNECT_LIST_DOMAINS_ACTIVE | VIR_CONNECT_LIST_DOMAINS_INACTIVE; @@ -64,18 +60,16 @@ showDomains(virConnectPtr conn) * unexpected results */ numActiveDomains =3D virConnectNumOfDomains(conn); if (numActiveDomains =3D=3D -1) { - ret =3D 1; printf("Failed to get number of active domains: %s\n", virGetLastErrorMessage()); - goto out; + return 1; } =20 numInactiveDomains =3D virConnectNumOfDefinedDomains(conn); if (numInactiveDomains =3D=3D -1) { - ret =3D 1; printf("Failed to get number of inactive domains: %s\n", virGetLastErrorMessage()); - goto out; + return 1; } =20 printf("There are %d active and %d inactive domains\n", @@ -89,10 +83,9 @@ showDomains(virConnectPtr conn) &nameList, flags); if (numNames =3D=3D -1) { - ret =3D 1; printf("Failed to get a list of all domains: %s\n", virGetLastErrorMessage()); - goto out; + return 1; } =20 for (i =3D 0; i < numNames; i++) { @@ -105,8 +98,7 @@ showDomains(virConnectPtr conn) } free(nameList); =20 - out: - return ret; + return 0; } =20 =20 @@ -126,10 +118,9 @@ main(int argc, char *argv[]) conn =3D virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0); =20 if (!conn) { - ret =3D 1; printf("No connection to hypervisor: %s\n", virGetLastErrorMessage()); - goto out; + return 1; } =20 uri =3D virConnectGetURI(conn); @@ -162,6 +153,5 @@ main(int argc, char *argv[]) printf("Disconnected from hypervisor\n"); } =20 - out: return ret; } diff --git a/examples/c/misc/openauth.c b/examples/c/misc/openauth.c index efd21c374f..4c9dd34be3 100644 --- a/examples/c/misc/openauth.c +++ b/examples/c/misc/openauth.c @@ -16,7 +16,7 @@ showError(virConnectPtr conn) err =3D malloc(sizeof(*err)); if (err =3D=3D NULL) { printf("Could not allocate memory for error data\n"); - goto out; + return; } =20 ret =3D virConnCopyLastError(conn, err); @@ -37,16 +37,12 @@ showError(virConnectPtr conn) =20 virResetError(err); free(err); - - out: - return; } =20 =20 static int showHypervisorInfo(virConnectPtr conn) { - int ret =3D 0; unsigned long hvVer, major, minor, release; const char *hvType; =20 @@ -56,17 +52,15 @@ showHypervisorInfo(virConnectPtr conn) * hypervisor, so check what it returns. */ hvType =3D virConnectGetType(conn); if (hvType =3D=3D NULL) { - ret =3D 1; printf("Failed to get hypervisor type\n"); showError(conn); - goto out; + return 1; } =20 if (virConnectGetVersion(conn, &hvVer) !=3D 0) { - ret =3D 1; printf("Failed to get hypervisor version\n"); showError(conn); - goto out; + return 1; } =20 major =3D hvVer / 1000000; @@ -80,8 +74,7 @@ showHypervisorInfo(virConnectPtr conn) minor, release); =20 - out: - return ret; + return 0; } =20 =20 @@ -227,9 +220,8 @@ main(int argc, char *argv[]) AuthData authData; =20 if (argc !=3D 4) { - ret =3D 1; printf("Usage: %s \n", argv[0]); - goto out; + return 1; } =20 uri =3D argv[1]; @@ -242,10 +234,9 @@ main(int argc, char *argv[]) conn =3D virConnectOpenAuth(uri, &auth, 0); =20 if (NULL =3D=3D conn) { - ret =3D 1; printf("No connection to hypervisor\n"); showError(conn); - goto out; + return 1; } =20 uri =3D virConnectGetURI(conn); @@ -278,6 +269,5 @@ main(int argc, char *argv[]) printf("Disconnected from hypervisor\n"); } =20 - out: return ret; } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list