Mesa (master): st/dri: Don't check for null when user ensures non-null

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Tue Apr 27 11:30:15 UTC 2010


Module: Mesa
Branch: master
Commit: 8fbd66d75a7b58a27ceb16bc23dfa5999cbe7483
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fbd66d75a7b58a27ceb16bc23dfa5999cbe7483

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Tue Apr 27 00:56:25 2010 +0100

st/dri: Don't check for null when user ensures non-null

---

 .../state_trackers/dri/common/dri_context.c        |   52 ++++++++-----------
 1 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index a144247..a808d2d 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -118,17 +118,15 @@ dri_destroy_context(__DRIcontext * cPriv)
 GLboolean
 dri_unbind_context(__DRIcontext * cPriv)
 {
+   /* dri_util.c ensures cPriv is not null */
    struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+   struct dri_context *ctx = dri_context(cPriv);
    struct st_api *stapi = screen->st_api;
 
-   if (cPriv) {
-      struct dri_context *ctx = dri_context(cPriv);
-
-      if (--ctx->bind_count == 0) {
-         if (ctx->st == stapi->get_current(stapi)) {
-            ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-            stapi->make_current(stapi, NULL, NULL, NULL);
-         }
+   if (--ctx->bind_count == 0) {
+      if (ctx->st == stapi->get_current(stapi)) {
+         ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+         stapi->make_current(stapi, NULL, NULL, NULL);
       }
    }
 
@@ -140,36 +138,30 @@ dri_make_current(__DRIcontext * cPriv,
 		 __DRIdrawable * driDrawPriv,
 		 __DRIdrawable * driReadPriv)
 {
+   /* dri_util.c ensures cPriv is not null */
    struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+   struct dri_context *ctx = dri_context(cPriv);
    struct st_api *stapi = screen->st_api;
+   struct dri_drawable *draw = dri_drawable(driDrawPriv);
+   struct dri_drawable *read = dri_drawable(driReadPriv);
+   struct st_context_iface *old_st = stapi->get_current(stapi);
 
-   if (cPriv) {
-      struct dri_context *ctx = dri_context(cPriv);
-      struct dri_drawable *draw = dri_drawable(driDrawPriv);
-      struct dri_drawable *read = dri_drawable(driReadPriv);
-      struct st_context_iface *old_st;
-
-      old_st = stapi->get_current(stapi);
-      if (old_st && old_st != ctx->st)
-	 old_st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
+   if (old_st && old_st != ctx->st)
+      old_st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-      ++ctx->bind_count;
+   ++ctx->bind_count;
 
-      if (ctx->dPriv != driDrawPriv) {
-	 ctx->dPriv = driDrawPriv;
-         draw->texture_stamp = driDrawPriv->lastStamp - 1;
-      }
-      if (ctx->rPriv != driReadPriv) {
-	 ctx->rPriv = driReadPriv;
-         read->texture_stamp = driReadPriv->lastStamp - 1;
-      }
-
-      stapi->make_current(stapi, ctx->st, &draw->base, &read->base);
+   if (ctx->dPriv != driDrawPriv) {
+      ctx->dPriv = driDrawPriv;
+      draw->texture_stamp = driDrawPriv->lastStamp - 1;
    }
-   else {
-      stapi->make_current(stapi, NULL, NULL, NULL);
+   if (ctx->rPriv != driReadPriv) {
+      ctx->rPriv = driReadPriv;
+      read->texture_stamp = driReadPriv->lastStamp - 1;
    }
 
+   stapi->make_current(stapi, ctx->st, &draw->base, &read->base);
+
    return GL_TRUE;
 }
 




More information about the mesa-commit mailing list