summaryrefslogtreecommitdiff
path: root/src/lib/tests/bitmap_test.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-05-24 15:08:33 +0200
committerdimitri staessens <[email protected]>2017-05-24 15:13:04 +0200
commita3ede18c5d3e652e9d0bade4b28193e666198574 (patch)
treee9c464bb98632d9b41f2bc5e7f9c2849e5405f5d /src/lib/tests/bitmap_test.c
parent3d887b172c37c4418c6173048e6a317eb0c36e57 (diff)
downloadouroboros-a3ede18c5d3e652e9d0bade4b28193e666198574.tar.gz
ouroboros-a3ede18c5d3e652e9d0bade4b28193e666198574.zip
lib: Fix bug in bitmap
Diffstat (limited to 'src/lib/tests/bitmap_test.c')
-rw-r--r--src/lib/tests/bitmap_test.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/tests/bitmap_test.c b/src/lib/tests/bitmap_test.c
index e438f217..4f58de3b 100644
--- a/src/lib/tests/bitmap_test.c
+++ b/src/lib/tests/bitmap_test.c
@@ -30,7 +30,7 @@
int bitmap_test(int argc, char ** argv)
{
struct bmp * bmp;
- size_t bits = BITMAP_SIZE;
+ ssize_t bits = BITMAP_SIZE;
ssize_t id;
int i;
ssize_t r;
@@ -57,8 +57,19 @@ int bitmap_test(int argc, char ** argv)
for (i = offset; i < BITMAP_SIZE + 5 + offset; i++) {
id = bmp_allocate(bmp);
- if (!bmp_is_id_valid(bmp, id))
+ if (!bmp_is_id_valid(bmp, id)) {
+ if (i < BITMAP_SIZE + offset) {
+ printf("Failed valid ID %d (%zd).\n", i, id);
+ bmp_destroy(bmp);
+ return -1;
+ }
+ if (id >= offset && id < bits + offset) {
+ printf("Valid ID %zd returned invalid.\n", id);
+ bmp_destroy(bmp);
+ return -1;
+ }
continue;
+ }
if (!bmp_is_id_used(bmp, id)) {
printf("ID not marked in use.\n");