x86: Address "Bitwise-and with zero CONSTANT_EXPRESSION_RESULT" Coverity issues
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 Jun 2018 12:26:36 +0000 (13:26 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 4 Jul 2018 11:12:15 +0000 (12:12 +0100)
Coverity complains at code which which performs a bitwise and with a constant
that happens to be zero.  Rearrange the C to test the constant first and short
circuit the bitwise and.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <JBeulich@suse.com>
xen/arch/x86/mm.c

index 4629bcaa47947c46d74c4e0ecf7c026e0bd9ca21..a1a1f5f3c3ebd181cf6dc8c7469b1a947db2c250 100644 (file)
@@ -1225,7 +1225,7 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner)
      * (Note that the undestroyable active grants are not a security hole in
      * Xen. All active grants can safely be cleaned up when the domain dies.)
      */
-    if ( (l1e_get_flags(l1e) & _PAGE_GNTTAB) &&
+    if ( _PAGE_GNTTAB && (l1e_get_flags(l1e) & _PAGE_GNTTAB) &&
          !l1e_owner->is_shutting_down && !l1e_owner->is_dying )
     {
         gdprintk(XENLOG_WARNING,