tools/ocaml: Fix 2 bit-twiddling bugs and an off-by-one
authorJon Ludlam <jonathan.ludlam@eu.citrix.com>
Mon, 10 Oct 2011 15:41:16 +0000 (16:41 +0100)
committerJon Ludlam <jonathan.ludlam@eu.citrix.com>
Mon, 10 Oct 2011 15:41:16 +0000 (16:41 +0100)
The bit bugs are in ocaml vcpu affinity calls, and the off-by-one
error is in the ocaml console ring code

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
tools/ocaml/libs/xc/xenctrl_stubs.c

index b57b50cb172b5d15b3432aa8b76dc91b24db05a1..03923e8c6a4ff07ae58a328377b55ad6998de304 100644 (file)
@@ -430,7 +430,7 @@ CAMLprim value stub_xc_vcpu_setaffinity(value xch, value domid,
 
        for (i=0; i<len; i++) {
                if (Bool_val(Field(cpumap, i)))
-                       c_cpumap[i/8] |= i << (i&7);
+                       c_cpumap[i/8] |= 1 << (i&7);
        }
        retval = xc_vcpu_setaffinity(_H(xch), _D(domid),
                                     Int_val(vcpu), c_cpumap);
@@ -466,7 +466,7 @@ CAMLprim value stub_xc_vcpu_getaffinity(value xch, value domid,
        ret = caml_alloc(len, 0);
 
        for (i=0; i<len; i++) {
-               if (c_cpumap[i%8] & 1 << (i&7))
+               if (c_cpumap[i/8] & 1 << (i&7))
                        Store_field(ret, i, Val_true);
                else
                        Store_field(ret, i, Val_false);
@@ -523,7 +523,7 @@ static char ring[RING_SIZE];
 
 CAMLprim value stub_xc_readconsolering(value xch)
 {
-       unsigned int size = RING_SIZE;
+       unsigned int size = RING_SIZE - 1;
        char *ring_ptr = ring;
 
        CAMLparam1(xch);