diff options
author | Eric Blake <eblake@redhat.com> | 2012-09-18 17:20:03 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2012-09-18 17:47:06 -0600 |
commit | fd66ea669c131f660799bb6f9ea9988a17cd03ef (patch) | |
tree | 2b867eb99fa86f65b17feb57bd7396886ca542de /src | |
parent | build: avoid non-portable byte-swapping (diff) | |
download | libvirt-fd66ea669c131f660799bb6f9ea9988a17cd03ef.tar.gz libvirt-fd66ea669c131f660799bb6f9ea9988a17cd03ef.tar.bz2 libvirt-fd66ea669c131f660799bb6f9ea9988a17cd03ef.zip |
bitmap: fix problems in previous commit
Commit ee3d3893 missed the fact that (unsigned char)<<(int)
is truncated to int, and therefore failed for any bitmap data
longer than four bytes.
Also, I failed to run 'make syntax-check' on my commit 4bba6579;
for whatever odd reason, ffs lives in a different header than ffsl.
* src/util/bitmap.c (virBitmapNewData): Use correct shift type.
(includes): Glibc (and therefore gnulib) decided ffs is in
<strings.h>, but ffsl is in <string.h>.
* tests/virbitmaptest.c (test5): Test it.
Diffstat (limited to 'src')
-rw-r--r-- | src/util/bitmap.c | 3 |
1 files changed, 1 insertions, 2 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; |