]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Xen: fix various checks of unsigned integers < 0
authorKeir Fraser <keir@xen.org>
Fri, 29 Oct 2010 17:44:54 +0000 (18:44 +0100)
committerKeir Fraser <keir@xen.org>
Fri, 29 Oct 2010 17:44:54 +0000 (18:44 +0100)
Some of these could be benignly discarded by the compiler but some are
actual bugs.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
xen-unstable changeset:   22336:49803ac994f4
xen-unstable date:        Fri Oct 29 18:05:50 2010 +0100

xen/arch/x86/mm.c
xen/arch/x86/physdev.c
xen/arch/x86/platform_hypercall.c
xen/arch/x86/x86_emulate/x86_emulate.c
xen/drivers/cpufreq/cpufreq.c

index 594247a83a0c6180e3926b6803a9ac468d46fef2..9705598fe2a112b01aa6141be63833fa142455f0 100644 (file)
@@ -4223,7 +4223,7 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p)
         ent.size = (uint64_t)(s - ctxt->s) << PAGE_SHIFT;
         ent.type = E820_RESERVED;
         buffer = guest_handle_cast(ctxt->map.buffer, e820entry_t);
-        if ( __copy_to_guest_offset(buffer, ctxt->n, &ent, 1) < 0 )
+        if ( __copy_to_guest_offset(buffer, ctxt->n, &ent, 1) )
             return -EFAULT;
         ctxt->n++;
     }
@@ -4439,7 +4439,7 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
             }
             if ( ctxt.map.nr_entries <= ctxt.n + (e820.nr_map - i) )
                 return -EINVAL;
-            if ( __copy_to_guest_offset(buffer, ctxt.n, e820.map + i, 1) < 0 )
+            if ( __copy_to_guest_offset(buffer, ctxt.n, e820.map + i, 1) )
                 return -EFAULT;
             ctxt.s = PFN_UP(e820.map[i].addr + e820.map[i].size);
         }
index baaff24ba2fb7d3394754872a21057a073c0ecc2..6a12f0013e2978af31ad40264451b9bb46fe80f8 100644 (file)
@@ -202,7 +202,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         if ( copy_from_guest(&eoi, arg, 1) != 0 )
             break;
         ret = -EINVAL;
-        if ( eoi.irq < 0 || eoi.irq >= v->domain->nr_pirqs )
+        if ( eoi.irq >= v->domain->nr_pirqs )
             break;
         if ( v->domain->arch.pirq_eoi_map )
             evtchn_unmask(v->domain->pirq_to_evtchn[eoi.irq]);
index e7f3283c1573afd2114942600b1e46ea16b7d18a..e2b4fe0152987b66d4bc300439ec449fab5135d6 100644 (file)
@@ -413,7 +413,6 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
         }
 
         if ( (g_info->xen_cpuid >= NR_CPUS) ||
-             (g_info->xen_cpuid < 0) ||
              !cpu_present(g_info->xen_cpuid) )
         {
             g_info->flags |= XEN_PCPU_FLAGS_INVALID;
index 51e199adbc55bd0a595e1089b99ad9ed20a002a1..7ad0dd5d2f92363da09320c03ee1e43e614d0d2f 100644 (file)
@@ -2102,7 +2102,7 @@ x86_emulate(
             _regs.edx = (uint32_t)(((int32_t)_regs.eax < 0) ? -1 : 0);
             break;
         case 8:
-            _regs.edx = (_regs.eax < 0) ? -1 : 0;
+            _regs.edx = ((int64_t)_regs.eax < 0) ? -1 : 0;
             break;
         }
         break;
index 627435d88c1146326badd27ceb189d1173c5a0ea..8243143126a2a4ee8b67cc0e92eef479fcae24ef 100644 (file)
@@ -115,8 +115,7 @@ int cpufreq_limit_change(unsigned int cpu)
     if (!cpu_online(cpu) || !data || !processor_pminfo[cpu])
         return -ENODEV;
 
-    if ((perf->platform_limit < 0) || 
-        (perf->platform_limit >= perf->state_count))
+    if (perf->platform_limit >= perf->state_count)
         return -EINVAL;
 
     memcpy(&policy, data, sizeof(struct cpufreq_policy));