From nobody Fri Apr 19 09:30:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539865633344396.1764697276277; Thu, 18 Oct 2018 05:27:13 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 0206B30025F6; Thu, 18 Oct 2018 12:27:11 +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 929B910018F8; Thu, 18 Oct 2018 12:27:10 +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 EF6723D60; Thu, 18 Oct 2018 12:27:09 +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 w9ICR7Sc025890 for ; Thu, 18 Oct 2018 08:27:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD0A260922; Thu, 18 Oct 2018 12:27:07 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E8A360D58 for ; Thu, 18 Oct 2018 12:27:07 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 18 Oct 2018 14:26:40 +0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [snmp PATCH 02/20] libvirtSnmp.c: Retab and realign 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 18 Oct 2018 12:27:12 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This file contains tabs, is misaligned and ugly. Fix this. Signed-off-by: Michal Privoznik --- src/libvirtSnmp.c | 175 +++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 88 deletions(-) diff --git a/src/libvirtSnmp.c b/src/libvirtSnmp.c index 2bd8f01..805cd6f 100644 --- a/src/libvirtSnmp.c +++ b/src/libvirtSnmp.c @@ -98,18 +98,18 @@ showError(virConnectPtr conn) break; =20 case -1: - snmp_log(LOG_ERR, "Parameter error when attempting to get last error\= n"); + snmp_log(LOG_ERR, "Parameter error when attempting to get last err= or\n"); break; =20 default: - snmp_log(LOG_ERR, "libvirt reported: \"%s\"\n", err->message); + snmp_log(LOG_ERR, "libvirt reported: \"%s\"\n", err->message); break; } =20 virResetError(err); free(err); =20 -out: + out: return; } =20 @@ -185,7 +185,7 @@ insertGuest(netsnmp_container *container, virDomainPtr = domain) goto out; } =20 -out: + out: return ret; } =20 @@ -218,8 +218,8 @@ libvirtSnmpLoadGuests(netsnmp_container *container) } =20 numIds =3D virConnectListDomains(conn, - idList, - numActiveDomains); + idList, + numActiveDomains); =20 if (-1 =3D=3D numIds) { ret =3D -1; @@ -233,7 +233,7 @@ libvirtSnmpLoadGuests(netsnmp_container *container) if (NULL =3D=3D domain) { printf("Failed to lookup domain\n"); showError(conn); - ret =3D -1; + ret =3D -1; goto out; } =20 @@ -263,8 +263,8 @@ libvirtSnmpLoadGuests(netsnmp_container *container) } =20 numNames =3D virConnectListDefinedDomains(conn, - nameList, - numDefinedDomains); + nameList, + numDefinedDomains); =20 if (-1 =3D=3D numNames) { ret =3D -1; @@ -290,16 +290,17 @@ libvirtSnmpLoadGuests(netsnmp_container *container) goto out_inact; } =20 -out_inact: + out_inact: free(nameList); -out: + out: free(idList); return ret; } =20 /* Polling thread function */ void * -pollingThreadFunc(void *foo) { +pollingThreadFunc(void *foo) +{ while (run) { #ifdef LIBVIRT_OLD if (virEventPollRunOnce() < 0) { @@ -341,8 +342,7 @@ libvirtRegisterEvents(virConnectPtr conn) { pthread_attr_init(&thread_attr); pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); =20 - if (pthread_create - (&poll_thread, &thread_attr, pollingThreadFunc, NULL)) + if (pthread_create(&poll_thread, &thread_attr, pollingThreadFunc, NULL= )) return -1; =20 pthread_attr_destroy(&thread_attr); @@ -373,13 +373,12 @@ int libvirtSnmpInit(void) if (virEventPollInit() < 0) return -1; =20 - virEventRegisterImpl( - virEventPollAddHandle, - virEventPollUpdateHandle, - virEventPollRemoveHandle, - virEventPollAddTimeout, - virEventPollUpdateTimeout, - virEventPollRemoveTimeout); + virEventRegisterImpl(virEventPollAddHandle, + virEventPollUpdateHandle, + virEventPollRemoveHandle, + virEventPollAddTimeout, + virEventPollUpdateTimeout, + virEventPollRemoveTimeout); #else virEventRegisterDefaultImpl(); #endif @@ -437,95 +436,95 @@ void libvirtSnmpShutdown(void) int libvirtSnmpCheckDomainExists(unsigned char *uuid) { - virDomainPtr d =3D virDomainLookupByUUID(conn, uuid); - if (d =3D=3D NULL) - return -1; + virDomainPtr d =3D virDomainLookupByUUID(conn, uuid); + if (d =3D=3D NULL) + return -1; =20 - virDomainFree(d); - return 0; + virDomainFree(d); + return 0; } =20 int libvirtSnmpCreate(unsigned char *uuid, int state) { - virDomainPtr dom; - int ret; - unsigned int flags =3D 0; + virDomainPtr dom; + int ret; + unsigned int flags =3D 0; =20 - dom =3D virDomainLookupByUUID(conn, uuid); - if (dom =3D=3D NULL) { - printf("Cannot find domain to create\n"); - return -1; - } + dom =3D virDomainLookupByUUID(conn, uuid); + if (dom =3D=3D NULL) { + printf("Cannot find domain to create\n"); + return -1; + } =20 - switch(state) { - case VIR_DOMAIN_RUNNING: - flags =3D 0; - break; - case VIR_DOMAIN_PAUSED: - flags =3D VIR_DOMAIN_START_PAUSED; - break; - default: - printf("Can't create domain with state %d\n", flags); - return -1; - } + switch(state) { + case VIR_DOMAIN_RUNNING: + flags =3D 0; + break; + case VIR_DOMAIN_PAUSED: + flags =3D VIR_DOMAIN_START_PAUSED; + break; + default: + printf("Can't create domain with state %d\n", flags); + return -1; + } =20 - ret =3D virDomainCreateWithFlags(dom, flags); - if (ret) { - showError(conn); - } - virDomainFree(dom); - return ret; + ret =3D virDomainCreateWithFlags(dom, flags); + if (ret) { + showError(conn); + } + virDomainFree(dom); + return ret; } =20 int libvirtSnmpDestroy(unsigned char *uuid) { - virDomainPtr dom; - int ret; + virDomainPtr dom; + int ret; =20 - dom =3D virDomainLookupByUUID(conn, uuid); - if (dom =3D=3D NULL) { - printf("Cannot find domain to destroy\n"); - return -1; - } + dom =3D virDomainLookupByUUID(conn, uuid); + if (dom =3D=3D NULL) { + printf("Cannot find domain to destroy\n"); + return -1; + } =20 - ret =3D virDomainDestroy(dom); - if (ret) { - showError(conn); - } - virDomainFree(dom); - return ret; + ret =3D virDomainDestroy(dom); + if (ret) { + showError(conn); + } + virDomainFree(dom); + return ret; } =20 int libvirtSnmpChangeState(unsigned char *uuid, int newstate, int oldstate) { - virDomainPtr dom; - int ret =3D 0; + virDomainPtr dom; + int ret =3D 0; =20 - dom =3D virDomainLookupByUUID(conn, uuid); - if (dom =3D=3D NULL) { - printf("Cannot find domain to change\n"); - return 1; - } + dom =3D virDomainLookupByUUID(conn, uuid); + if (dom =3D=3D NULL) { + printf("Cannot find domain to change\n"); + return 1; + } =20 - if (oldstate =3D=3D VIR_DOMAIN_RUNNING && newstate =3D=3D VIR_DOMAIN_PAUS= ED) - ret =3D virDomainSuspend(dom); - else if (oldstate =3D=3D VIR_DOMAIN_PAUSED && newstate =3D=3D VIR_DOMAIN_= RUNNING) - ret =3D virDomainResume(dom); - else if (newstate =3D=3D VIR_DOMAIN_SHUTDOWN) - ret =3D virDomainShutdown(dom); - else { - printf("Wrong state transition from %d to %d\n", oldstate, newstate); - ret =3D -1; - goto out; - } + if (oldstate =3D=3D VIR_DOMAIN_RUNNING && newstate =3D=3D VIR_DOMAIN_P= AUSED) + ret =3D virDomainSuspend(dom); + else if (oldstate =3D=3D VIR_DOMAIN_PAUSED && newstate =3D=3D VIR_DOMA= IN_RUNNING) + ret =3D virDomainResume(dom); + else if (newstate =3D=3D VIR_DOMAIN_SHUTDOWN) + ret =3D virDomainShutdown(dom); + else { + printf("Wrong state transition from %d to %d\n", oldstate, newstat= e); + ret =3D -1; + goto out; + } =20 - if (ret !=3D 0) { - showError(conn); - } -out: - virDomainFree(dom); - return ret; + if (ret !=3D 0) { + showError(conn); + } + out: + virDomainFree(dom); + return ret; } --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list