gallium: fix warnings in release build
[mesa.git] / src / gallium / drivers / r600 / compute_memory_pool.c
index 9324b84bd61c2e931d1dd0f32fdac6b942a142bd..bcda155c71aa5c227ffd70051c0a98a0a284bdb2 100644 (file)
@@ -26,7 +26,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
 #include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_transfer.h"
 #include "util/u_surface.h"
 #include "util/u_pack_color.h"
@@ -51,7 +51,7 @@ struct compute_memory_pool* compute_memory_pool_new(
 {
        struct compute_memory_pool* pool = (struct compute_memory_pool*)
                                CALLOC(sizeof(struct compute_memory_pool), 1);
-       if (pool == NULL)
+       if (!pool)
                return NULL;
 
        COMPUTE_DBG(rscreen, "* compute_memory_pool_new()\n");
@@ -80,8 +80,8 @@ static void compute_memory_pool_init(struct compute_memory_pool * pool,
                initial_size_in_dw);
 
        pool->size_in_dw = initial_size_in_dw;
-       pool->bo = (struct r600_resource*)r600_compute_buffer_alloc_vram(pool->screen,
-                                                       pool->size_in_dw * 4);
+       pool->bo = r600_compute_buffer_alloc_vram(pool->screen,
+                                                 pool->size_in_dw * 4);
 }
 
 /**
@@ -95,6 +95,12 @@ void compute_memory_pool_delete(struct compute_memory_pool* pool)
                pool->screen->b.b.resource_destroy((struct pipe_screen *)
                        pool->screen, (struct pipe_resource *)pool->bo);
        }
+       /* In theory, all of the items were freed in compute_memory_free.
+        * Just delete the list heads
+        */
+       free(pool->item_list);
+       free(pool->unallocated_list);
+       /* And then the pool itself */
        free(pool);
 }
 
@@ -114,7 +120,7 @@ int64_t compute_memory_prealloc_chunk(
 
        assert(size_in_dw <= pool->size_in_dw);
 
-       COMPUTE_DBG(pool->screen, "* compute_memory_prealloc_chunk() size_in_dw = %ld\n",
+       COMPUTE_DBG(pool->screen, "* compute_memory_prealloc_chunk() size_in_dw = %"PRIi64"\n",
                size_in_dw);
 
        LIST_FOR_EACH_ENTRY(item, pool->item_list, link) {
@@ -145,7 +151,7 @@ struct list_head *compute_memory_postalloc_chunk(
        struct compute_memory_item *next;
        struct list_head *next_link;
 
-       COMPUTE_DBG(pool->screen, "* compute_memory_postalloc_chunck() start_in_dw = %ld\n",
+       COMPUTE_DBG(pool->screen, "* compute_memory_postalloc_chunck() start_in_dw = %"PRIi64"\n",
                start_in_dw);
 
        /* Check if we can insert it in the front of the list */
@@ -196,8 +202,7 @@ int compute_memory_grow_defrag_pool(struct compute_memory_pool *pool,
        } else {
                struct r600_resource *temp = NULL;
 
-               temp = (struct r600_resource *)r600_compute_buffer_alloc_vram(
-                                                       pool->screen, new_size_in_dw * 4);
+               temp = r600_compute_buffer_alloc_vram(pool->screen, new_size_in_dw * 4);
 
                if (temp != NULL) {
                        struct pipe_resource *src = (struct pipe_resource *)pool->bo;
@@ -228,9 +233,7 @@ int compute_memory_grow_defrag_pool(struct compute_memory_pool *pool,
                        pool->screen->b.b.resource_destroy(
                                        (struct pipe_screen *)pool->screen,
                                        (struct pipe_resource *)pool->bo);
-                       pool->bo = (struct r600_resource*)r600_compute_buffer_alloc_vram(
-                                       pool->screen,
-                                       pool->size_in_dw * 4);
+                       pool->bo = r600_compute_buffer_alloc_vram(pool->screen, pool->size_in_dw * 4);
                        compute_memory_shadow(pool, pipe, 0);
 
                        if (pool->status & POOL_FRAGMENTED) {
@@ -396,7 +399,7 @@ int compute_memory_promote_item(struct compute_memory_pool *pool,
        list_addtail(&item->link, pool->item_list);
        item->start_in_dw = start_in_dw;
 
-       if (src != NULL) {
+       if (src) {
                u_box_1d(0, item->size_in_dw * 4, &box);
 
                rctx->b.b.resource_copy_region(pipe,
@@ -443,7 +446,7 @@ void compute_memory_demote_item(struct compute_memory_pool *pool,
        /* We check if the intermediate buffer exists, and if it
         * doesn't, we create it again */
        if (item->real_buffer == NULL) {
-               item->real_buffer = (struct r600_resource*)r600_compute_buffer_alloc_vram(
+               item->real_buffer = r600_compute_buffer_alloc_vram(
                                pool->screen, item->size_in_dw * 4);
        }
 
@@ -486,7 +489,7 @@ void compute_memory_move_item(struct compute_memory_pool *pool,
        struct r600_context *rctx = (struct r600_context *)pipe;
        struct pipe_box box;
 
-       struct compute_memory_item *prev;
+       MAYBE_UNUSED struct compute_memory_item *prev;
 
        COMPUTE_DBG(pool->screen, "* compute_memory_move_item()\n"
                        "  + Moving item %"PRIi64" from %"PRIi64" (%"PRIi64" bytes) to %"PRIu64" (%"PRIu64" bytes)\n",
@@ -562,7 +565,7 @@ void compute_memory_free(struct compute_memory_pool* pool, int64_t id)
        struct pipe_screen *screen = (struct pipe_screen *)pool->screen;
        struct pipe_resource *res;
 
-       COMPUTE_DBG(pool->screen, "* compute_memory_free() id + %ld \n", id);
+       COMPUTE_DBG(pool->screen, "* compute_memory_free() id + %"PRIi64" \n", id);
 
        LIST_FOR_EACH_ENTRY_SAFE(item, next, pool->item_list, link) {
 
@@ -622,12 +625,12 @@ struct compute_memory_item* compute_memory_alloc(
 {
        struct compute_memory_item *new_item = NULL;
 
-       COMPUTE_DBG(pool->screen, "* compute_memory_alloc() size_in_dw = %ld (%ld bytes)\n",
+       COMPUTE_DBG(pool->screen, "* compute_memory_alloc() size_in_dw = %"PRIi64" (%"PRIi64" bytes)\n",
                        size_in_dw, 4 * size_in_dw);
 
        new_item = (struct compute_memory_item *)
                                CALLOC(sizeof(struct compute_memory_item), 1);
-       if (new_item == NULL)
+       if (!new_item)
                return NULL;
 
        new_item->size_in_dw = size_in_dw;