test: fix Coverity complaints

seat_button_count
seat_key_count ... uninitialized variable

t = zalloc
s = zalloc ... dereferencing potential NULL-pointer

d->ntouches_down... side-effect in assertion

Coverity run against the 0.10.0 tag, see
https://scan.coverity.com/projects/4298

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Christian Hartmann <cornogle@googlemail.com>
This commit is contained in:
Peter Hutterer 2015-02-19 07:22:59 +10:00
parent 002ef1635d
commit ed0f0bf494
3 changed files with 9 additions and 4 deletions

View file

@ -36,7 +36,7 @@ START_TEST(keyboard_seat_key_count)
struct libinput_event *ev;
struct libinput_event_keyboard *kev;
int i;
int seat_key_count;
int seat_key_count = 0;
int expected_key_button_count = 0;
char device_name[255];

View file

@ -184,6 +184,7 @@ litest_add_tcase_for_device(struct suite *suite,
}
t = zalloc(sizeof(*t));
assert(t != NULL);
t->name = strdup(test_name);
t->tc = tcase_create(test_name);
list_insert(&suite->tests, &t->node);
@ -215,6 +216,7 @@ litest_add_tcase_no_device(struct suite *suite, void *func)
}
t = zalloc(sizeof(*t));
assert(t != NULL);
t->name = strdup(test_name);
t->tc = tcase_create(test_name);
list_insert(&suite->tests, &t->node);
@ -270,6 +272,7 @@ get_suite(const char *name)
}
s = zalloc(sizeof(*s));
assert(s != NULL);
s->name = strdup(name);
s->suite = suite_create(s->name);
@ -808,7 +811,8 @@ litest_touch_down(struct litest_device *d, unsigned int slot,
{
struct input_event *ev;
assert(++d->ntouches_down > 0);
assert(d->ntouches_down >= 0);
d->ntouches_down++;
send_btntool(d);
@ -836,7 +840,8 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
{ .type = -1, .code = -1 }
};
assert(--d->ntouches_down >= 0);
assert(d->ntouches_down > 0);
d->ntouches_down--;
send_btntool(d);

View file

@ -470,7 +470,7 @@ START_TEST(pointer_seat_button_count)
struct libinput_event *ev;
struct libinput_event_pointer *tev;
int i;
int seat_button_count;
int seat_button_count = 0;
int expected_seat_button_count = 0;
char device_name[255];