]> xenbits.xensource.com Git - xen.git/commitdiff
avoid left shifting into a sign bit
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 18 Feb 2016 14:07:59 +0000 (15:07 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 18 Feb 2016 14:07:59 +0000 (15:07 +0100)
Clang 3.8 notices, and objects because it is undefined behaviour.

"error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]"

Use unsigned constants rather than signed ones.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Feng Wu <feng.wu@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/page_alloc.c
xen/drivers/passthrough/vtd/x86/ats.c

index 624a2667af8d2603fe5f29994a03ad44e5d21bdd..7179d677e7ec2ddeb39ece35e4ace770d588a285 100644 (file)
@@ -1675,7 +1675,7 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
     ASSERT(!in_irq());
 
     if ( xenheap_bits && (memflags >> _MEMF_bits) > xenheap_bits )
-        memflags &= ~MEMF_bits(~0);
+        memflags &= ~MEMF_bits(~0U);
     if ( !(memflags >> _MEMF_bits) )
         memflags |= MEMF_bits(xenheap_bits);
 
index 7c797f6bed0325dbe6983ad63bff4bee03ead5a7..334b9c1159ca03ddd33a6f82183b49cd4ed716d2 100644 (file)
@@ -133,7 +133,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
         case DMA_TLB_GLOBAL_FLUSH:
             /* invalidate all translations: sbit=1,bit_63=0,bit[62:12]=1 */
             sbit = 1;
-            addr = (~0 << PAGE_SHIFT_4K) & 0x7FFFFFFFFFFFFFFF;
+            addr = (~0UL << PAGE_SHIFT_4K) & 0x7FFFFFFFFFFFFFFF;
             rc = qinval_device_iotlb(iommu, pdev->ats_queue_depth,
                                      sid, sbit, addr);
             break;
@@ -145,7 +145,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
             sbit = size_order ? 1 : 0;
 
             /* clear lower bits */
-            addr &= ~0 << PAGE_SHIFT_4K;
+            addr &= ~0UL << PAGE_SHIFT_4K;
 
             /* if sbit == 1, zero out size_order bit and set lower bits to 1 */
             if ( sbit )