[libvirt] [snmp PATCH 17/20] libvirtSnmp: Fix type of libvirtUnregisterEvents()

Michal Privoznik posted 20 patches 5 years, 7 months ago
[libvirt] [snmp PATCH 17/20] libvirtSnmp: Fix type of libvirtUnregisterEvents()
Posted by Michal Privoznik 5 years, 7 months ago
This function returns only a single value. It makes no sense to
have it return that. Make it return void.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/libvirtSnmp.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/libvirtSnmp.c b/src/libvirtSnmp.c
index 3a93bc6..2f2f406 100644
--- a/src/libvirtSnmp.c
+++ b/src/libvirtSnmp.c
@@ -227,14 +227,14 @@ libvirtRegisterEvents(virConnectPtr conn)
 }
 
 /* Unregister domain events collection */
-int
+static void
 libvirtUnregisterEvents(virConnectPtr conn)
 {
-    void *status;
+    if (callbackRet < 0)
+        return;
 
     virConnectDomainEventDeregisterAny(conn, callbackRet);
     callbackRet = -1;
-    return 0;
 }
 
 int libvirtSnmpInit(void)
@@ -284,13 +284,11 @@ void libvirtSnmpShutdown(void)
     if (timer != -1)
         virEventRemoveTimeout(timer);
 
-    if (libvirtUnregisterEvents(conn)) {
-        printf("Failed to unregister domain events\n");
-    }
+    libvirtUnregisterEvents(conn);
 
     if ((rc = virConnectClose(conn))) {
         printLibvirtError("Failed to disconnect from hypervisor. "
-                  "Leaked references: %d\n", rc);
+                          "Leaked references: %d\n", rc);
     }
 }
 
-- 
2.18.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [snmp PATCH 17/20] libvirtSnmp: Fix type of libvirtUnregisterEvents()
Posted by Martin Kletzander 5 years, 7 months ago
On Thu, Oct 18, 2018 at 02:26:55PM +0200, Michal Privoznik wrote:
>This function returns only a single value. It makes no sense to
>have it return that. Make it return void.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/libvirtSnmp.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
>diff --git a/src/libvirtSnmp.c b/src/libvirtSnmp.c
>index 3a93bc6..2f2f406 100644
>--- a/src/libvirtSnmp.c
>+++ b/src/libvirtSnmp.c
>@@ -227,14 +227,14 @@ libvirtRegisterEvents(virConnectPtr conn)
> }
>
> /* Unregister domain events collection */
>-int
>+static void
> libvirtUnregisterEvents(virConnectPtr conn)
> {
>-    void *status;
>+    if (callbackRet < 0)
>+        return;
>
>     virConnectDomainEventDeregisterAny(conn, callbackRet);
>     callbackRet = -1;
>-    return 0;
> }
>
> int libvirtSnmpInit(void)
>@@ -284,13 +284,11 @@ void libvirtSnmpShutdown(void)
>     if (timer != -1)
>         virEventRemoveTimeout(timer);
>
>-    if (libvirtUnregisterEvents(conn)) {
>-        printf("Failed to unregister domain events\n");
>-    }
>+    libvirtUnregisterEvents(conn);
>
>     if ((rc = virConnectClose(conn))) {
>         printLibvirtError("Failed to disconnect from hypervisor. "
>-                  "Leaked references: %d\n", rc);
>+                          "Leaked references: %d\n", rc);

This hunk probably should've been part of the s/showError/printLibvirtError/
patch

>     }
> }
>
>-- 
>2.18.1
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list