...to minimise misuse of bo_gem. If the variable is declared at the top of the function and then used for two (or more) different contexts this can cause confusion and errors. Just introduce a wrapper, which can be used in a once off situations. Suggested-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Signed-off-by: Emil Velikov <emil.l.velikov@xxxxxxxxx> --- intel/intel_bufmgr_gem.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 5287419..63122d0 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -276,6 +276,11 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo); static void drm_intel_gem_bo_free(drm_intel_bo *bo); +static inline drm_intel_bo_gem *to_bo_gem(drm_intel_bo *bo) +{ + return (drm_intel_bo_gem *)bo; +} + static unsigned long drm_intel_gem_bo_tile_size(drm_intel_bufmgr_gem *bufmgr_gem, unsigned long size, uint32_t *tiling_mode) @@ -2116,11 +2121,10 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, drm_clip_rect_t * cliprects, int num_cliprects, int DR4) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; struct drm_i915_gem_execbuffer execbuf; int ret, i; - if (bo_gem->has_error) + if (to_bo_gem(bo)->has_error) return -ENOMEM; pthread_mutex_lock(&bufmgr_gem->lock); @@ -2165,7 +2169,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, drm_intel_gem_dump_validation_list(bufmgr_gem); for (i = 0; i < bufmgr_gem->exec_count; i++) { - bo_gem = (drm_intel_bo_gem *) bufmgr_gem->exec_bos[i]; + drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]); bo_gem->idle = false; @@ -2185,12 +2189,11 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx, unsigned int flags) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr; - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; struct drm_i915_gem_execbuffer2 execbuf; int ret = 0; int i; - if (bo_gem->has_error) + if (to_bo_gem(bo)->has_error) return -ENOMEM; switch (flags & 0x7) { @@ -2263,7 +2266,7 @@ skip_execution: drm_intel_gem_dump_validation_list(bufmgr_gem); for (i = 0; i < bufmgr_gem->exec_count; i++) { - bo_gem = (drm_intel_bo_gem *) bufmgr_gem->exec_bos[i]; + drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]); bo_gem->idle = false; -- 2.5.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel