[Mesa-dev] [PATCH] gallium: fix clang warnings

Nicolai Hähnle nhaehnle at gmail.com
Tue Sep 6 15:29:51 UTC 2016


On 06.09.2016 16:37, Martina Kollarova wrote:
> 1. Variable 'hole' is uninitialized when used here [-Wuninitialized]
> 2. Comparison of constant -1 with expression of type 'unsigned int' is always
>    false [-Wtautological-constant-out-of-range-compare]
> ---
>  src/gallium/winsys/radeon/drm/radeon_drm_bo.c     | 2 +-
>  src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 5 -----
>  2 files changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
> index 56aab48..23ee8d5 100644
> --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
> @@ -200,7 +200,7 @@ static uint64_t radeon_bomgr_find_va(struct radeon_drm_winsys *rws,
>  static void radeon_bomgr_free_va(struct radeon_drm_winsys *rws,
>                                   uint64_t va, uint64_t size)
>  {
> -    struct radeon_bo_va_hole *hole;
> +    struct radeon_bo_va_hole *hole = NULL;

This is a false positive, but sure, why not.

>
>      size = align(size, rws->info.gart_page_size);
>
> 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..33f6850 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
> @@ -259,11 +259,6 @@ kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd,
>     kms_sw_dt->height = height;
>     kms_sw_dt->stride = stride;
>
> -   if (kms_sw_dt->size == (off_t)-1) {
> -      FREE(kms_sw_dt);
> -      return NULL;
> -   }

NAK. You're just papering over the real bug here, which is that size 
comes from the return value of lseek, which may be -1 on error, and the 
compiler seems to be telling you that it might "optimize" the error 
check away.

Nicolai

> -
>     lseek(fd, 0, SEEK_SET);
>
>     list_add(&kms_sw_dt->link, &kms_sw->bo_list);
>


More information about the mesa-dev mailing list