[Intel-gfx] [PATCH i-g-t] lib/igt_kms: Fix build warning in igt_display_drop_events

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 10 17:46:58 UTC 2018


Quoting Tvrtko Ursulin (2018-01-09 12:47:04)
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> Check read(2) return for robustness and to silence gcc.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>

Hmm, mildly concerned about ev.length. A long time ago when I was last
in the event queue, we guaranteed writing whole requests and nothing but
whole requests.

> ---
>  lib/igt_kms.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index ec3b716791a2..c8f30d2c8a54 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3155,10 +3155,11 @@ int igt_display_drop_events(igt_display_t *display)
>                 struct drm_event ev;
>                 char buf[128];
>  
> -               read(display->drm_fd, &ev, sizeof(ev));
> +               igt_assert_eq(read(display->drm_fd, &ev, sizeof(ev)),
> +                             sizeof(ev));
>                 igt_info("Dropping event type %u length %u\n", ev.type, ev.length);
>                 igt_assert(ev.length <= sizeof(buf));
> -               read(display->drm_fd, buf, ev.length);
> +               igt_assert_eq(read(display->drm_fd, buf, ev.length), ev.length);

What we do in drm_read() is

	copy_to_user(buffer, e->event, e->event->length)

so this read here is too long (as its sizeof(event) + event.length). The
assert will one day blow up... But only because the code is incorrect.
-Chris


More information about the Intel-gfx mailing list