[Mesa-dev] [PATCH 1/4] st/xvmc: use goto to make code more readable
Nayan Deshmukh
nayan26deshmukh at gmail.com
Thu Dec 15 13:34:11 UTC 2016
Signed-off-by: Nayan Deshmukh <nayan26deshmukh at gmail.com>
---
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..469e1c1 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
--
2.9.3
More information about the mesa-dev
mailing list