[RFC PATCH v1 06/15] node_device_udev: Test for mdevctlTimeout != -1

Marc Hartmayer posted 15 patches 1 year, 10 months ago
There is a newer version of this series
[RFC PATCH v1 06/15] node_device_udev: Test for mdevctlTimeout != -1
Posted by Marc Hartmayer 1 year, 10 months ago
It is done a little differently everywhere in libvirt, but most common is to
test for != -1.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
 src/node_device/node_device_udev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 1d3be28f8f08..469538a1395d 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -88,7 +88,7 @@ udevEventDataDispose(void *obj)
     if (priv->watch != -1)
         virEventRemoveHandle(priv->watch);
 
-    if (priv->mdevctlTimeout > 0)
+    if (priv->mdevctlTimeout != -1)
         virEventRemoveTimeout(priv->mdevctlTimeout);
 
     if (!priv->udev_monitor)
@@ -139,6 +139,7 @@ udevEventDataNew(void)
         return NULL;
     }
 
+    ret->mdevctlTimeout = -1;
     ret->watch = -1;
     return ret;
 }
@@ -2086,7 +2087,7 @@ launchMdevctlUpdateThread(int timer G_GNUC_UNUSED, void *opaque)
     udevEventData *priv = opaque;
     virThread thread;
 
-    if (priv->mdevctlTimeout > 0) {
+    if (priv->mdevctlTimeout != -1) {
         virEventRemoveTimeout(priv->mdevctlTimeout);
         priv->mdevctlTimeout = -1;
     }
@@ -2196,7 +2197,7 @@ scheduleMdevctlUpdate(udevEventData *data,
                       bool force)
 {
     if (!force) {
-        if (data->mdevctlTimeout > 0)
+        if (data->mdevctlTimeout != -1)
             virEventRemoveTimeout(data->mdevctlTimeout);
         data->mdevctlTimeout = virEventAddTimeout(100, launchMdevctlUpdateThread,
                                                   data, NULL);
-- 
2.34.1
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [RFC PATCH v1 06/15] node_device_udev: Test for mdevctlTimeout != -1
Posted by Jonathon Jongsma 1 year, 9 months ago
On 4/12/24 8:36 AM, Marc Hartmayer wrote:
> It is done a little differently everywhere in libvirt, but most common is to
> test for != -1.
> 
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> ---
>   src/node_device/node_device_udev.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
> index 1d3be28f8f08..469538a1395d 100644
> --- a/src/node_device/node_device_udev.c
> +++ b/src/node_device/node_device_udev.c
> @@ -88,7 +88,7 @@ udevEventDataDispose(void *obj)
>       if (priv->watch != -1)
>           virEventRemoveHandle(priv->watch);
>   
> -    if (priv->mdevctlTimeout > 0)
> +    if (priv->mdevctlTimeout != -1)
>           virEventRemoveTimeout(priv->mdevctlTimeout);
>   
>       if (!priv->udev_monitor)
> @@ -139,6 +139,7 @@ udevEventDataNew(void)
>           return NULL;
>       }
>   
> +    ret->mdevctlTimeout = -1;
>       ret->watch = -1;
>       return ret;
>   }
> @@ -2086,7 +2087,7 @@ launchMdevctlUpdateThread(int timer G_GNUC_UNUSED, void *opaque)
>       udevEventData *priv = opaque;
>       virThread thread;
>   
> -    if (priv->mdevctlTimeout > 0) {
> +    if (priv->mdevctlTimeout != -1) {
>           virEventRemoveTimeout(priv->mdevctlTimeout);
>           priv->mdevctlTimeout = -1;
>       }
> @@ -2196,7 +2197,7 @@ scheduleMdevctlUpdate(udevEventData *data,
>                         bool force)
>   {
>       if (!force) {
> -        if (data->mdevctlTimeout > 0)
> +        if (data->mdevctlTimeout != -1)
>               virEventRemoveTimeout(data->mdevctlTimeout);
>           data->mdevctlTimeout = virEventAddTimeout(100, launchMdevctlUpdateThread,
>                                                     data, NULL);


OK

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org