test: add assert()s to fix analyzer warnings
Reduce the analyzer spam a bit by adding some extra asserts. Since it's test code, we can't have enough of them anyways ;-) Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
be4f551d9f
commit
00080db825
|
@ -75,8 +75,10 @@ get_image(struct test_setup *setup, xcb_drawable_t drawable)
|
|||
assert(reply->depth == 24);
|
||||
assert(len == 4 * setup->width * setup->height);
|
||||
|
||||
uint32_t *result = malloc(sizeof(uint32_t) *
|
||||
setup->width * setup->height);
|
||||
uint32_t *result = calloc(setup->width * setup->height, sizeof(uint32_t));
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
memcpy(result, data, len);
|
||||
free(reply);
|
||||
|
||||
|
@ -93,7 +95,9 @@ compute_expected_damage(struct test_setup *setup)
|
|||
uint32_t *results = get_image(setup, setup->d);
|
||||
bool any_modified_pixels = false;
|
||||
|
||||
assert(results);
|
||||
for (int i = 0; i < setup->width * setup->height; i++) {
|
||||
assert(setup->start_drawable_contents);
|
||||
if (results[i] != setup->start_drawable_contents[i]) {
|
||||
setup->expected[i / 32] |= 1 << (i % 32);
|
||||
any_modified_pixels = true;
|
||||
|
|
|
@ -242,6 +242,7 @@ test_nt_list_append(void)
|
|||
struct foo *item;
|
||||
|
||||
for (item = foo, i = 1; i <= 10; i++, item++) {
|
||||
assert(item);
|
||||
item->a = i;
|
||||
item->b = i * 2;
|
||||
nt_list_init(item, next);
|
||||
|
@ -273,6 +274,7 @@ test_nt_list_insert(void)
|
|||
{
|
||||
int i;
|
||||
struct foo *foo = calloc(10, sizeof(struct foo));
|
||||
assert(foo);
|
||||
struct foo *item;
|
||||
|
||||
foo->a = 1;
|
||||
|
@ -309,6 +311,8 @@ test_nt_list_delete(void)
|
|||
{
|
||||
int i = 1;
|
||||
struct foo *list = calloc(10, sizeof(struct foo));
|
||||
assert(list);
|
||||
|
||||
struct foo *foo = list;
|
||||
struct foo *item, *tmp;
|
||||
struct foo *empty_list = foo;
|
||||
|
|
|
@ -52,6 +52,8 @@ strndup_checks(void)
|
|||
char *firsthalf = strndup(sample, 8);
|
||||
char *secondhalf = strndup(sample + 8, 8);
|
||||
|
||||
assert(firsthalf);
|
||||
assert(secondhalf);
|
||||
assert(strcmp(firsthalf, "01234567") == 0);
|
||||
assert(strcmp(secondhalf, "89abcdef") == 0);
|
||||
|
||||
|
@ -59,6 +61,7 @@ strndup_checks(void)
|
|||
free(secondhalf);
|
||||
|
||||
allofit = strndup(sample, 20);
|
||||
assert(allofit);
|
||||
assert(strcmp(allofit, sample) == 0);
|
||||
free(allofit);
|
||||
}
|
||||
|
|
|
@ -153,6 +153,17 @@ xkb_set_get_rules_test(void)
|
|||
|
||||
/* This test is iffy, because strictly we may be comparing against already
|
||||
* freed memory */
|
||||
assert(rmlvo.rules);
|
||||
assert(rmlvo.model);
|
||||
assert(rmlvo.layout);
|
||||
assert(rmlvo.variant);
|
||||
assert(rmlvo.options);
|
||||
assert(rmlvo_backup.rules);
|
||||
assert(rmlvo_backup.model);
|
||||
assert(rmlvo_backup.layout);
|
||||
assert(rmlvo_backup.variant);
|
||||
assert(rmlvo_backup.options);
|
||||
|
||||
assert(strcmp(rmlvo.rules, rmlvo_backup.rules) == 0);
|
||||
assert(strcmp(rmlvo.model, rmlvo_backup.model) == 0);
|
||||
assert(strcmp(rmlvo.layout, rmlvo_backup.layout) == 0);
|
||||
|
|
|
@ -57,6 +57,7 @@ fake_init_sprite(DeviceIntPtr dev)
|
|||
|
||||
sprite->spriteTraceSize = 10;
|
||||
sprite->spriteTrace = calloc(sprite->spriteTraceSize, sizeof(WindowPtr));
|
||||
assert(sprite->spriteTrace);
|
||||
sprite->spriteTraceGood = 1;
|
||||
sprite->spriteTrace[0] = &root;
|
||||
sprite->hot.x = SPRITE_X;
|
||||
|
|
|
@ -59,10 +59,12 @@ xi2mask_test(void)
|
|||
assert(xi2mask_num_masks(xi2mask) == xi2mask->nmasks);
|
||||
|
||||
mask = calloc(1, xi2mask_mask_size(xi2mask));
|
||||
assert(mask);
|
||||
|
||||
/* ensure zeros */
|
||||
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
|
||||
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
|
||||
|
||||
assert(mask);
|
||||
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
|
||||
}
|
||||
|
||||
|
@ -77,6 +79,9 @@ xi2mask_test(void)
|
|||
|
||||
m = xi2mask_get_one_mask(xi2mask, i);
|
||||
SetBit(mask, i);
|
||||
assert(mask);
|
||||
assert(m);
|
||||
if (mask)
|
||||
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
|
||||
ClearBit(mask, i);
|
||||
}
|
||||
|
@ -85,6 +90,7 @@ xi2mask_test(void)
|
|||
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
|
||||
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
|
||||
|
||||
assert(mask);
|
||||
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) != 0);
|
||||
xi2mask_zero(xi2mask, i);
|
||||
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
|
||||
|
@ -97,7 +103,7 @@ xi2mask_test(void)
|
|||
|
||||
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
|
||||
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
|
||||
|
||||
assert(mask);
|
||||
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue