gallium: fix return value check

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@amd.com>
Signed-off-by: Martina Kollarova <martina.kollarova@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
This commit is contained in:
Martina Kollarova 2016-09-08 15:12:42 +03:00 committed by Emil Velikov
parent ab29788250
commit 2527e18eeb
1 changed files with 8 additions and 8 deletions

View File

@ -252,17 +252,17 @@ kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd,
if (!kms_sw_dt)
return NULL;
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) {
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->width = width;
kms_sw_dt->height = height;
kms_sw_dt->stride = stride;
lseek(fd, 0, SEEK_SET);