[Mesa-dev] [PATCH v2] gallium: fix return value check
Eric Engestrom
eric.engestrom at imgtec.com
Wed Sep 14 12:47:47 UTC 2016
On Thu, Sep 08, 2016 at 03:12:42PM +0300, Martina Kollarova wrote:
> A possible error (-1) was being lost because it was first converted to an
> unsigned int and only then checked.
>
> Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
> Signed-off-by: Martina Kollarova <martina.kollarova at intel.com>
Good cleanup :)
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
By the way, I noticed this hasn't landed, after almost a week.
Would anyone care to push it? Nicolai?
Cheers,
Eric
> ---
> src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
> index 07eca99..22e1c93 100644
> --- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
> +++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
> @@ -252,18 +252,18 @@ kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd,
> if (!kms_sw_dt)
> return NULL;
>
> + off_t lseek_ret = lseek(fd, 0, SEEK_END);
> + if (lseek_ret == -1) {
> + FREE(kms_sw_dt);
> + return NULL;
> + }
> + kms_sw_dt->size = lseek_ret;
> kms_sw_dt->ref_count = 1;
> kms_sw_dt->handle = handle;
> - kms_sw_dt->size = lseek(fd, 0, SEEK_END);
> kms_sw_dt->width = width;
> kms_sw_dt->height = height;
> kms_sw_dt->stride = stride;
>
> - if (kms_sw_dt->size == (off_t)-1) {
> - FREE(kms_sw_dt);
> - return NULL;
> - }
> -
> lseek(fd, 0, SEEK_SET);
>
> list_add(&kms_sw_dt->link, &kms_sw->bo_list);
> --
> 1.9.1
More information about the mesa-dev
mailing list