[Intel-gfx] [PATCH i-g-t 1/2] tests/{kms_cursor_legacy, drv_missed_irq}, lib/drmtest: Fix warnings about unused function return values.

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 23 19:53:37 UTC 2016


On Thu, Jun 23, 2016 at 07:46:02PM +0300, Marius Vlad wrote:
> Signed-off-by: Marius Vlad <marius.c.vlad at intel.com>
> CC: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  lib/drmtest.c             | 8 +++-----
>  tests/drv_missed_irq.c    | 2 +-
>  tests/kms_cursor_legacy.c | 8 ++++++--
>  3 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 9a1232f..1e28f60 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);
>  }
>  
>  /**
> @@ -236,8 +236,6 @@ static void modprobe(const char *driver)
>   */
>  int __drm_open_driver(int chipset)
>  {
> -	if (chipset & DRIVER_VGEM)
> -		modprobe("vgem");

If you don't modprobe it first...

>  	for (int i = 0; i < 16; i++) {
>  		char name[80];
> @@ -258,7 +256,7 @@ int __drm_open_driver(int chipset)
>  
>  		if (chipset & DRIVER_VGEM &&
>  		    is_vgem_device(fd))
> -			return fd;
> +			return (modprobe("vgem") == -1) ? -1 : fd;

it won't be available as /dev/dri/cardN.

As I noted, we do *NOT* care about the return value of the system call.

>  		close(fd);
>  	}
> diff --git a/tests/drv_missed_irq.c b/tests/drv_missed_irq.c
> index 66d20ed..130a6aa 100644
> --- a/tests/drv_missed_irq.c
> +++ b/tests/drv_missed_irq.c
> @@ -130,7 +130,7 @@ igt_simple_main
>  	fclose(file);
>  
>  	file = igt_debugfs_fopen("i915_ring_test_irq", "r");
> -	fscanf(file, "%x", &expect_rings);
> +	igt_assert_eq(fscanf(file, "%x", &expect_rings), 1);

NO.

>  	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 00890c9..2228e99 100644
> --- a/tests/kms_cursor_legacy.c
> +++ b/tests/kms_cursor_legacy.c
> @@ -238,6 +238,7 @@ static void flip(struct data *data,
>  	}
>  	igt_fork(child, 1) {
>  		unsigned long count = 0;
> +		ssize_t nread;
>  		unsigned crtc = data->resources->crtcs[flip_pipe];
>  
>  		igt_until_timeout(timeout) {
> @@ -245,7 +246,8 @@ static void flip(struct data *data,
>  			drmModePageFlip(data->fd, crtc, fb_id,
>  					DRM_MODE_PAGE_FLIP_EVENT,
>  					NULL);
> -			read(data->fd, buf, sizeof(buf));
> +			nread = read(data->fd, buf, sizeof(buf));
> +			igt_assert_eq(nread, sizeof(buf));

NO.

>  			count++;
>  		}
>  
> @@ -286,6 +288,7 @@ static void basic_flip(struct data *data)
>  	struct igt_fb fb_info;
>  	unsigned vblank_start;
>  	int target;
> +	ssize_t nread;
>  	struct drm_event buf;
>  	uint32_t fb_id;
>  
> @@ -338,7 +341,8 @@ 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));
> +	nread = read(data->fd, &buf, sizeof(buf));

NO, NO, NO.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list