]> xenbits.xensource.com Git - libvirt.git/commitdiff
node_device_udev: Make the code easier to read
authorMarc Hartmayer <mhartmay@linux.ibm.com>
Tue, 23 Apr 2024 18:09:03 +0000 (20:09 +0200)
committerJonathon Jongsma <jjongsma@redhat.com>
Tue, 18 Jun 2024 14:00:33 +0000 (09:00 -0500)
There is only one case where force is true, therefore let's inline that case.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
src/node_device/node_device_udev.c

index 69f877505407d1b8160c226ac155ada3dc1d7919..af640d6f2b7cbe9b81b65413bea3f7fecc4e790a 100644 (file)
@@ -2210,21 +2210,14 @@ mdevctlEnableMonitor(udevEventData *priv)
 
 /* Schedules an mdevctl update for 100ms in the future, canceling any existing
  * timeout that may have been set. In this way, multiple update requests in
- * quick succession can be collapsed into a single update. if @force is true,
- * the worker job is submitted immediately. */
+ * quick succession can be collapsed into a single update. */
 static void
-scheduleMdevctlUpdate(udevEventData *data,
-                      bool force)
-{
-    if (!force) {
-        if (data->mdevctlTimeout != -1)
-            virEventRemoveTimeout(data->mdevctlTimeout);
-        data->mdevctlTimeout = virEventAddTimeout(100, submitMdevctlUpdate,
-                                                  data, NULL);
-        return;
-    }
-
-    submitMdevctlUpdate(-1, data);
+scheduleMdevctlUpdate(udevEventData *data)
+{
+    if (data->mdevctlTimeout != -1)
+        virEventRemoveTimeout(data->mdevctlTimeout);
+    data->mdevctlTimeout = virEventAddTimeout(100, submitMdevctlUpdate,
+                                              data, NULL);
 }
 
 
@@ -2259,7 +2252,11 @@ mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED,
      * CHANGES_DONE_HINT event. As a fallback,  add a timeout to trigger the
      * signal if that event never comes */
     VIR_WITH_OBJECT_LOCK_GUARD(priv) {
-        scheduleMdevctlUpdate(priv, (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT));
+        if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
+            submitMdevctlUpdate(-1, priv);
+        } else {
+            scheduleMdevctlUpdate(priv);
+        }
     }
 }