From d86d6eb281ba99fca1bb39ad3dc05c5681dded5d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 23 Jun 2016 21:07:36 +0100 Subject: Silence compiler warnings for expected and handled error conditions Silly compiler emitting warnings that just cause people to break code attempting to silence the compiler. Signed-off-by: Chris Wilson --- lib/drmtest.c | 4 ++-- lib/igt_core.h | 11 +++++++++++ tests/drv_missed_irq.c | 3 ++- tests/kms_cursor_legacy.c | 6 ++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 9a1232f4..632fec41 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -218,11 +218,11 @@ int drm_get_card(void) return -1; } -static void modprobe(const char *driver) +static int modprobe(const char *driver) { char buf[128]; snprintf(buf, sizeof(buf), "/sbin/modprobe -s %s", driver); - system(buf); + return system(buf); } /** diff --git a/lib/igt_core.h b/lib/igt_core.h index 59952331..64d823f6 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -296,6 +296,17 @@ void __igt_fail_assert(const char *domain, const char *file, __attribute__((noreturn)); void igt_exit(void) __attribute__((noreturn)); +/** + * igt_ignore_warn: + * @expr: condition to ignore + * + * + * Stops the compiler warning about an unused return value. + */ +static inline void igt_ignore_warn(bool value) +{ +} + /** * igt_assert: * @expr: condition to test diff --git a/tests/drv_missed_irq.c b/tests/drv_missed_irq.c index 66d20edb..d0d9b391 100644 --- a/tests/drv_missed_irq.c +++ b/tests/drv_missed_irq.c @@ -129,8 +129,9 @@ igt_simple_main fprintf(file, "0x%x", -1); fclose(file); + expect_rings = -1; file = igt_debugfs_fopen("i915_ring_test_irq", "r"); - fscanf(file, "%x", &expect_rings); + igt_ignore_warn(fscanf(file, "%x", &expect_rings)); fclose(file); igt_debug("Testing rings %x\n", expect_rings); diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c index 00890c95..d98de526 100644 --- a/tests/kms_cursor_legacy.c +++ b/tests/kms_cursor_legacy.c @@ -245,7 +245,9 @@ static void flip(struct data *data, drmModePageFlip(data->fd, crtc, fb_id, DRM_MODE_PAGE_FLIP_EVENT, NULL); - read(data->fd, buf, sizeof(buf)); + while (read(data->fd, buf, sizeof(buf)) < 0 && + (errno == EINTR || errno == EAGAIN)) + ; count++; } @@ -338,7 +340,7 @@ static void basic_flip(struct data *data) igt_assert_eq(get_vblank(data->fd, 0, 0), vblank_start); igt_set_timeout(1, "Stuck page flip"); - read(data->fd, &buf, sizeof(buf)); + igt_ignore_warn(read(data->fd, &buf, sizeof(buf))); igt_assert_eq(get_vblank(data->fd, 0, 0), vblank_start + 1); igt_reset_timeout(); -- cgit v1.2.3