]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Replace if-else-if sequence in SyncWorker() with switch
authorPaul Durrant <pdurrant@amazon.com>
Fri, 6 May 2022 11:29:54 +0000 (12:29 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Fri, 6 May 2022 12:49:10 +0000 (13:49 +0100)
Now that the set of requests and other re-factoring is complete, tidy up the
code in SyncWorker().

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
src/xenbus/sync.c

index b6665708a58e676a857e94ed3c60de0fef539dc2..5b2b76a47f580bee3e63330bd20b80961b37a0d1 100644 (file)
@@ -267,6 +267,8 @@ SyncWorker(
 
     Request = SYNC_REQUEST_NONE;
     for (;;) {
+        NTSTATUS status;
+
         KeMemoryBarrier();
 
         if (Context->Request == SYNC_REQUEST_EXIT)
@@ -277,20 +279,31 @@ SyncWorker(
             continue;
         }
 
-        if (Context->Request == SYNC_REQUEST_DISABLE_INTERRUPTS) {
-            NTSTATUS    status = __SyncProcessorDisableInterrupts();
-                    
-            if (!NT_SUCCESS(status))
-                continue;
-        } else if (Context->Request == SYNC_REQUEST_RUN_EARLY) {
+        status = STATUS_SUCCESS;
+
+        switch (Context->Request) {
+        case SYNC_REQUEST_DISABLE_INTERRUPTS:
+            status = __SyncProcessorDisableInterrupts();
+            break;
+
+        case SYNC_REQUEST_RUN_EARLY:
             __SyncProcessorRunEarly(Index);
-        } else if (Context->Request == SYNC_REQUEST_ENABLE_INTERRUPTS) {
+            break;
+
+        case SYNC_REQUEST_ENABLE_INTERRUPTS:
             __SyncProcessorEnableInterrupts();
-        } else if (Context->Request == SYNC_REQUEST_RUN_LATE) {
+            break;
+
+        case SYNC_REQUEST_RUN_LATE:
             __SyncProcessorRunLate(Index);
+            break;
+
+        default:
+            break;
         }
 
-        Request = Context->Request;
+        if (NT_SUCCESS(status))
+            Request = Context->Request;
     }
 
     Trace("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);