]> xenbits.xensource.com Git - people/aperard/xtf.git/commitdiff
various: Fix scan-build deadcode.DeadStores issues
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 15 Apr 2021 01:03:00 +0000 (02:03 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Apr 2021 22:41:56 +0000 (23:41 +0100)
Scan-build complains:

  main.c:164:15: warning: Although the value stored to 'cr4' is used in the enclosing expression, the value is never actually read from 'cr4' [deadcode.DeadStores]
      write_cr4(cr4 &= ~X86_CR4_DE);
                ^      ~~~~~~~~~~~

Rework all impacted logic avoid dead stores of this form.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
tests/debug-regs/main.c
tests/nested-vmx/vmxon.c
tests/pv-fsgsbase/main.c
tests/xsa-269/main.c

index 9d4b74e9284baacd51f8a60bdfd2b41312f4a366..19c888977dcaac95ae549af673d8e9d01d122483 100644 (file)
@@ -138,7 +138,7 @@ static void test_pv_dr7_io_breakpoints(void)
     printk("Test PV %%dr7 IO breakpoints\n");
 
     if ( !(cr4 & X86_CR4_DE) )
-        write_cr4(cr4 |= X86_CR4_DE);
+        write_cr4(cr4 | X86_CR4_DE);
 
     /* Active IO breakpoint in %dr0. */
     io0 = DR7_SYM(0, G, IO, 32) | X86_DR7_GE | X86_DR7_DEFAULT;
@@ -161,7 +161,7 @@ static void test_pv_dr7_io_breakpoints(void)
     write_dr7(io0);
 
     /* Clear %cr4.de, after which IO breakpoints are invalid. */
-    write_cr4(cr4 &= ~X86_CR4_DE);
+    write_cr4(cr4);
 
     /* Attempt to reload an IO breakpoint in %dr0, which should fail ... */
     exinfo_t fault = 0;
index 74b1182c09a3481eec585043c5a80fbae75621fe..e101288e5387a3010a4ca4391099061f17f47a79 100644 (file)
@@ -181,7 +181,7 @@ void test_vmxon(void)
     test_vmxon_novmxe();
     test_vmxon_novmxe_in_user();
 
-    write_cr4(cr4 |= X86_CR4_VMXE);
+    write_cr4(cr4 | X86_CR4_VMXE);
 
     test_vmxon_in_user();
     test_vmxon_overly_wide_paddr();
index d354238545d98bf4968714c067ff57086a1c9ed5..de966c94ef63f7df93dea9faa2d49399198ecda6 100644 (file)
@@ -174,7 +174,9 @@ void test_main(void)
     {
         xtf_failure("Fail: Initial CR4.FSGSBASE state should be clear\n");
 
-        if ( pv_write_cr4_safe(cr4 &= ~X86_CR4_FSGSBASE) )
+        /* Try turning CR4.FSGSBASE off, to continue the test. */
+        cr4 &= ~X86_CR4_FSGSBASE;
+        if ( pv_write_cr4_safe(cr4) )
             return xtf_failure("Fail: Fault while trying to clear CR4.FSGSBASE\n");
     }
 
@@ -187,14 +189,14 @@ void test_main(void)
     if ( !cpu_has_fsgsbase )
     {
         /* If the FSGSBASE feature isn't visible, check we can't turn it on. */
-        if ( !pv_write_cr4_safe(cr4 |= X86_CR4_FSGSBASE) )
+        if ( !pv_write_cr4_safe(cr4 | X86_CR4_FSGSBASE) )
             xtf_failure("Fail: Able to set CR4.FSGSBASE without the feature\n");
 
         return;
     }
 
     /* Check we can turn CR4.FSGSBASE on. */
-    if ( pv_write_cr4_safe(cr4 |= X86_CR4_FSGSBASE) )
+    if ( pv_write_cr4_safe(cr4 | X86_CR4_FSGSBASE) )
         xtf_failure("Fail: Unable to enable CR4.FSGSBASE\n");
 
     /* Check that {RD,WR}{FS,GS}BASE instructions are enabled. */
@@ -204,7 +206,7 @@ void test_main(void)
     test_wrfsbase_values();
 
     /* Check we can turn CR4.FSGSBASE off again. */
-    if ( pv_write_cr4_safe(cr4 &= ~X86_CR4_FSGSBASE) )
+    if ( pv_write_cr4_safe(cr4) )
         xtf_failure("Fail: Unable to enable CR4.FSGSBASE\n");
 
     /* Check that {RD,WR}{FS,GS}BASE instructions are disabled again. */
index d633d50ea117452f22406d8116138d1806ed594d..164a6021495c305cc5d813840d25c595f14a6c0d 100644 (file)
@@ -43,7 +43,7 @@ void test_main(void)
      */
     wrmsr_safe(MSR_DEBUGCTL, val |= DEBUGCTL_TR);
     wrmsr_safe(MSR_DEBUGCTL, val |= DEBUGCTL_BTS);
-    wrmsr_safe(MSR_DEBUGCTL, val |= DEBUGCTL_BTINT);
+    wrmsr_safe(MSR_DEBUGCTL, val |  DEBUGCTL_BTINT);
 
     /*
      * If we're still alive, generate a billion jumps to check that BTS really