From f9532700bc9135cc774fb5e78dd2dab248dbe0b2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sat, 29 Jun 2013 18:10:01 +1000 Subject: [PATCH] test: provide uinput convenience function for varargs Signed-off-by: Peter Hutterer --- test/test-common-uinput.c | 17 +++++++++++++---- test/test-common-uinput.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/test-common-uinput.c b/test/test-common-uinput.c index 607f2d2..d0b8e21 100644 --- a/test/test-common-uinput.c +++ b/test/test-common-uinput.c @@ -66,10 +66,9 @@ uinput_device_new(const char *name) } int -uinput_device_new_with_events(struct uinput_device **d, const char *name, const struct input_id *id, ...) +uinput_device_new_with_events_v(struct uinput_device **d, const char *name, const struct input_id *id, va_list args) { int rc; - va_list args; struct uinput_device *dev; dev = uinput_device_new(name); @@ -78,9 +77,7 @@ uinput_device_new_with_events(struct uinput_device **d, const char *name, const if (id != DEFAULT_IDS) uinput_device_set_ids(dev, id); - va_start(args, id); rc = uinput_device_set_event_bits_v(dev, args); - va_end(args); if (rc == 0) rc = uinput_device_create(dev); @@ -94,6 +91,18 @@ uinput_device_new_with_events(struct uinput_device **d, const char *name, const return rc; } +int +uinput_device_new_with_events(struct uinput_device **d, const char *name, const struct input_id *id, ...) +{ + int rc; + va_list args; + + va_start(args, id); + rc = uinput_device_new_with_events_v(d, name, id, args); + va_end(args); + + return rc; +} void uinput_device_free(struct uinput_device *dev) diff --git a/test/test-common-uinput.h b/test/test-common-uinput.h index f195bde..e3829e2 100644 --- a/test/test-common-uinput.h +++ b/test/test-common-uinput.h @@ -28,6 +28,7 @@ struct uinput_device* uinput_device_new(const char *name); int uinput_device_new_with_events(struct uinput_device **dev, const char *name, const struct input_id *ids, ...); +int uinput_device_new_with_events_v(struct uinput_device **dev, const char *name, const struct input_id *ids, va_list args); void uinput_device_free(struct uinput_device *dev); int uinput_device_create(struct uinput_device* dev); -- 2.7.4