[waffle] [PATCH 06/13] all: remove 'self' NULL check from *_context_destroy()
Emil Velikov
emil.l.velikov at gmail.com
Mon May 16 10:54:42 UTC 2016
From: Emil Velikov <emil.velikov at collabora.com>
Analogous to previous commit
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/waffle/cgl/cgl_context.m | 7 ++-----
src/waffle/egl/wegl_context.c | 23 ++++++++++-------------
src/waffle/glx/glx_context.c | 17 +++++------------
src/waffle/nacl/nacl_context.c | 11 +++--------
src/waffle/wgl/wgl_context.c | 7 ++-----
5 files changed, 22 insertions(+), 43 deletions(-)
diff --git a/src/waffle/cgl/cgl_context.m b/src/waffle/cgl/cgl_context.m
index 7786113..5d3f575 100644
--- a/src/waffle/cgl/cgl_context.m
+++ b/src/waffle/cgl/cgl_context.m
@@ -36,13 +36,10 @@ bool
cgl_context_destroy(struct wcore_context *wc_self)
{
struct cgl_context *self = cgl_context(wc_self);
- bool ok = true;
-
- if (!self)
- return ok;
+ bool ok;
[self->ns release];
- ok &= wcore_context_teardown(wc_self);
+ ok = wcore_context_teardown(wc_self);
free(self);
return ok;
}
diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 41334eb..7f12b3a 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -214,23 +214,20 @@ fail:
bool
wegl_context_destroy(struct wcore_context *wc_ctx)
{
+ struct wegl_context *ctx = wegl_context(wc_ctx);
bool result = true;
- if (wc_ctx) {
- struct wegl_context *ctx = wegl_context(wc_ctx);
+ if (ctx->egl != EGL_NO_CONTEXT) {
+ struct wegl_display *dpy = wegl_display(ctx->wcore.display);
+ struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
- if (ctx && ctx->egl != EGL_NO_CONTEXT) {
- struct wegl_display *dpy = wegl_display(ctx->wcore.display);
- struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
-
- if (!plat->eglDestroyContext(dpy->egl, ctx->egl)) {
- wegl_emit_error(plat, "eglDestroyContext");
- result = false;
- }
+ if (!plat->eglDestroyContext(dpy->egl, ctx->egl)) {
+ wegl_emit_error(plat, "eglDestroyContext");
+ result = false;
}
-
- result &= wcore_context_teardown(&ctx->wcore);
- free(ctx);
}
+
+ result &= wcore_context_teardown(&ctx->wcore);
+ free(ctx);
return result;
}
diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c
index a553a6b..87adc28 100644
--- a/src/waffle/glx/glx_context.c
+++ b/src/waffle/glx/glx_context.c
@@ -51,22 +51,15 @@
bool
glx_context_destroy(struct wcore_context *wc_self)
{
- struct glx_context *self;
- struct glx_display *dpy;
- struct glx_platform *platform;
- bool ok = true;
-
- if (!wc_self)
- return ok;
-
- self = glx_context(wc_self);
- dpy = glx_display(wc_self->display);
- platform = glx_platform(wc_self->display->platform);
+ struct glx_context *self = glx_context(wc_self);
+ struct glx_display *dpy = glx_display(wc_self->display);
+ struct glx_platform *platform = glx_platform(wc_self->display->platform);
+ bool ok;
if (self->glx)
wrapped_glXDestroyContext(platform, dpy->x11.xlib, self->glx);
- ok &= wcore_context_teardown(wc_self);
+ ok = wcore_context_teardown(wc_self);
free(self);
return ok;
}
diff --git a/src/waffle/nacl/nacl_context.c b/src/waffle/nacl/nacl_context.c
index 52015c2..eba3213 100644
--- a/src/waffle/nacl/nacl_context.c
+++ b/src/waffle/nacl/nacl_context.c
@@ -32,17 +32,12 @@ bool
nacl_context_destroy(struct wcore_context *wc_self)
{
struct nacl_context *self = nacl_context(wc_self);
- struct nacl_platform *plat;
- bool ok = true;
-
- if (!wc_self)
- return ok;
-
- plat = nacl_platform(wc_self->display->platform);
+ struct nacl_platform *plat = nacl_platform(wc_self->display->platform);
+ bool ok;
nacl_container_context_fini(plat->nacl);
- ok &= wcore_context_teardown(wc_self);
+ ok = wcore_context_teardown(wc_self);
free(self);
return ok;
}
diff --git a/src/waffle/wgl/wgl_context.c b/src/waffle/wgl/wgl_context.c
index 9b732ab..c1ac7d8 100644
--- a/src/waffle/wgl/wgl_context.c
+++ b/src/waffle/wgl/wgl_context.c
@@ -39,15 +39,12 @@ bool
wgl_context_destroy(struct wcore_context *wc_self)
{
struct wgl_context *self = wgl_context(wc_self);
- bool ok = true;
-
- if (!self)
- return true;
+ bool ok;
if (self->hglrc)
ok &= wglDeleteContext(self->hglrc);
- ok &= wcore_context_teardown(wc_self);
+ ok = wcore_context_teardown(wc_self);
free(self);
return ok;
}
--
2.6.2
More information about the waffle
mailing list