aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util/bitmap.c3
-rw-r--r--tests/virbitmaptest.c12
2 files changed, 8 insertions, 7 deletions
diff --git a/src/util/bitmap.c b/src/util/bitmap.c
index 4bade6cbd..9ca1af88a 100644
--- a/src/util/bitmap.c
+++ b/src/util/bitmap.c
@@ -27,7 +27,6 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -434,7 +433,7 @@ virBitmapPtr virBitmapNewData(void *data, int len)
j = 0;
p++;
}
- *p |= bytes[i] << (j * CHAR_BIT);
+ *p |= (unsigned long) bytes[i] << (j * CHAR_BIT);
}
return bitmap;
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index 028556f06..71836def6 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -214,15 +214,15 @@ error:
/* test for virBitmapNewData/ToData */
static int test5(const void *v ATTRIBUTE_UNUSED)
{
- char data[] = {0x01, 0x02, 0x00, 0x00};
+ char data[] = {0x01, 0x02, 0x00, 0x00, 0x04};
unsigned char *data2 = NULL;
int len2;
- int bits[] = {0, 9};
+ int bits[] = {0, 9, 34};
virBitmapPtr bitmap;
int i, j;
int ret = -1;
- bitmap = virBitmapNewData(data, 4);
+ bitmap = virBitmapNewData(data, sizeof(data));
if (!bitmap)
goto error;
@@ -242,10 +242,12 @@ static int test5(const void *v ATTRIBUTE_UNUSED)
if (virBitmapToData(bitmap, &data2, &len2) < 0)
goto error;
- if (data2[0] != 0x05 ||
+ if (len2 != sizeof(data) ||
+ data2[0] != 0x05 ||
data2[1] != 0x82 ||
data2[2] != 0x00 ||
- data2[3] != 0x00)
+ data2[3] != 0x00 ||
+ data2[4] != 0x04)
goto error;
ret = 0;