[Mesa-dev] [PATCH 2/2] winsys/amdgpu: clean up and fix switch statement

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Tue Apr 19 23:35:34 UTC 2016


On Wed, Apr 20, 2016 at 1:13 AM, Grigori Goronzy <greg at chown.ath.cx> wrote:
> Add missing break, add default case. Additionally initialize variables
> to avoid compiler warnings.
> ---
>  src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> index b9a7c5b..d978a0d 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> @@ -202,12 +202,13 @@ static bool amdgpu_get_new_ib(struct radeon_winsys *ws, struct amdgpu_ib *ib,
>                                struct amdgpu_cs_ib_info *info, unsigned ib_type)
>  {
>     struct amdgpu_winsys *aws = (struct amdgpu_winsys *)ws;
> -   unsigned buffer_size, ib_size;
> +   unsigned buffer_size = 0, ib_size = 0;
>
>     switch (ib_type) {
>     case IB_CONST_PREAMBLE:
>        buffer_size = 4 * 1024 * 4;
>        ib_size = 1024 * 4;
> +      break;
>     case IB_CONST:
>        buffer_size = 512 * 1024 * 4;
>        ib_size = 128 * 1024 * 4;
> @@ -225,6 +226,9 @@ static bool amdgpu_get_new_ib(struct radeon_winsys *ws, struct amdgpu_ib *ib,
>        ib_size = 32 * 1024 * 4;
>        if (aws->buffer_wait_time_avg > IB_SIZE_WAIT_THRESHOLD_NS)
>           ib_size = 10 * 1024 * 4;
> +      break;
> +   default:
> +      assert(!"unreachable");

You can use the unreachable macro, this also puts a
__asume_unreachable() in there, so the compiler won't complain about
that path anymore.

- Bas

>     }
>
>     ib->base.cdw = 0;
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list