[Mesa-dev] [PATCH 1/5] st/xvmc: use goto to make code more readable (v2)
Christian König
deathsimple at vodafone.de
Thu Dec 22 11:26:27 UTC 2016
Am 16.12.2016 um 12:58 schrieb Nayan Deshmukh:
> v2: add missing semicolon
>
> Signed-off-by: Nayan Deshmukh <nayan26deshmukh at gmail.com>
Patch #2-#4 are Reviewed-by: Christian König <christian.koenig at amd.com>.
For patch #1 and #5 I'm a bit hesitated to add them without testing.
XvMC isn't widely used any more, but we should still try to not break it.
Maybe you can try to come up with something?
Regards,
Christian.
> ---
> src/gallium/state_trackers/xvmc/context.c | 40 +++++++++++++++----------------
> 1 file changed, 19 insertions(+), 21 deletions(-)
>
> diff --git a/src/gallium/state_trackers/xvmc/context.c b/src/gallium/state_trackers/xvmc/context.c
> index e9014c8..fb9f435 100644
> --- a/src/gallium/state_trackers/xvmc/context.c
> +++ b/src/gallium/state_trackers/xvmc/context.c
> @@ -226,23 +226,20 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
>
> context_priv = CALLOC(1, sizeof(XvMCContextPrivate));
> if (!context_priv)
> - return BadAlloc;
> + goto no_context_priv;
>
> /* TODO: Reuse screen if process creates another context */
> vscreen = vl_dri2_screen_create(dpy, scrn);
>
> if (!vscreen) {
> XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL screen.\n");
> - FREE(context_priv);
> - return BadAlloc;
> + goto no_screen;
> }
>
> pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen, 0);
> if (!pipe) {
> XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n");
> - vscreen->destroy(vscreen);
> - FREE(context_priv);
> - return BadAlloc;
> + goto no_context;
> }
>
> templat.profile = ProfileToPipe(mc_type);
> @@ -257,29 +254,17 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
>
> if (!context_priv->decoder) {
> XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n");
> - pipe->destroy(pipe);
> - vscreen->destroy(vscreen);
> - FREE(context_priv);
> - return BadAlloc;
> + goto no_decoder;
> }
>
> if (!vl_compositor_init(&context_priv->compositor, pipe)) {
> XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n");
> - context_priv->decoder->destroy(context_priv->decoder);
> - pipe->destroy(pipe);
> - vscreen->destroy(vscreen);
> - FREE(context_priv);
> - return BadAlloc;
> + goto no_compositor;
> }
>
> if (!vl_compositor_init_state(&context_priv->cstate, pipe)) {
> XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
> - vl_compositor_cleanup(&context_priv->compositor);
> - context_priv->decoder->destroy(context_priv->decoder);
> - pipe->destroy(pipe);
> - vscreen->destroy(vscreen);
> - FREE(context_priv);
> - return BadAlloc;
> + goto no_compositor_state;
> }
>
>
> @@ -313,6 +298,19 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
> XVMC_MSG(XVMC_TRACE, "[XvMC] Context %p created.\n", context);
>
> return Success;
> +
> +no_compositor_state:
> + vl_compositor_cleanup(&context_priv->compositor);
> +no_compositor:
> + context_priv->decoder->destroy(context_priv->decoder);
> +no_decoder:
> + pipe->destroy(pipe);
> +no_context:
> + vscreen->destroy(vscreen);
> +no_screen:
> + FREE(context_priv);
> +no_context_priv:
> + return BadAlloc;
> }
>
> PUBLIC
More information about the mesa-dev
mailing list