On Thu, Jun 28, 2012 at 09:51:56PM +0200, Johannes Obermayr wrote:
> ---
>  libkms/nouveau.c |   20 +++++++++++---------
>  1 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/libkms/nouveau.c b/libkms/nouveau.c
> index 0e24a15..4cbca96 100644
> --- a/libkms/nouveau.c
> +++ b/libkms/nouveau.c
> @@ -94,14 +94,18 @@ nouveau_bo_create(struct kms_driver *kms,
>       if (!bo)
>               return -ENOMEM;
>  
> -     if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
> +     switch (type) {
> +     case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
>               pitch = 64 * 4;
>               size = 64 * 64 * 4;
> -     } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
> +             break;
> +     case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
>               pitch = width * 4;
>               pitch = (pitch + 512 - 1) & ~(512 - 1);
>               size = pitch * height;
> -     } else {
> +             break;
> +     default:
> +             free(bo);
>               return -EINVAL;
>       }
>  
> @@ -114,8 +118,10 @@ nouveau_bo_create(struct kms_driver *kms,
>       arg.channel_hint = 0;
>  
>       ret = drmCommandWriteRead(kms->fd, DRM_NOUVEAU_GEM_NEW, &arg, 
> sizeof(arg));
> -     if (ret)
> -             goto err_free;
> +     if (ret) {
> +             free(bo);
> +             return ret;
> +     }
>  
>       bo->base.kms = kms;
>       bo->base.handle = arg.info.handle;
> @@ -126,10 +132,6 @@ nouveau_bo_create(struct kms_driver *kms,
>       *out = &bo->base;
>  
>       return 0;
> -
> -err_free:
> -     free(bo);
> -     return ret;
>  }
>  
>  static int
> -- 

Looks good, but moving bo allocation after type check would be simplier
(-3+3 lines patch) and have the same effect.

Marcin
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to