hw/i386/x86: Reverse if statement
authorBernhard Beschow <shentey@gmail.com>
Sat, 6 Jan 2024 13:25:44 +0000 (14:25 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 14 Feb 2024 11:09:32 +0000 (06:09 -0500)
The if statement currently uses double negation when executing the else branch.
So swap the branches and simplify the condition to make the code more
comprehensible.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-Id: <20240106132546.21248-2-shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/i386/x86.c

index 3d1bdd334ea50ade1e3078218245cc8cf7f50fc8..505f64f89c050fcec563e3f49e87cf402e03702b 100644 (file)
@@ -520,10 +520,10 @@ static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
     CPU_FOREACH(cs) {
         X86CPU *cpu = X86_CPU(cs);
 
-        if (!cpu->apic_state) {
-            cpu_interrupt(cs, CPU_INTERRUPT_NMI);
-        } else {
+        if (cpu->apic_state) {
             apic_deliver_nmi(cpu->apic_state);
+        } else {
+            cpu_interrupt(cs, CPU_INTERRUPT_NMI);
         }
     }
 }