From 308bb6726002056ccd7c89f7942f10ebc7d43ca9 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 8 Apr 2009 11:37:26 +0200 Subject: Fix valgrind warnings. Signed-off-by: Thomas Hellstrom --- src/wsbm_slabpool.c | 11 +++++++++-- src/wsbm_ttmpool.c | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/wsbm_slabpool.c b/src/wsbm_slabpool.c index abab436..99f8d22 100644 --- a/src/wsbm_slabpool.c +++ b/src/wsbm_slabpool.c @@ -241,6 +241,7 @@ wsbmFreeKernelBO(struct _WsbmSlabKernelBO *kbo) return; slabPool = kbo->slabPool; + memset(&arg, 0, sizeof(arg)); arg.handle = kbo->kBuf.handle; (void)munmap(kbo->virtual, kbo->actualSize); (void)drmCommandWrite(slabPool->pool.fd, @@ -369,6 +370,7 @@ wsbmAllocKernelBO(struct _WsbmSlabSizeHeader *header) struct ttm_pl_setstatus_req *req = &arg.req; struct ttm_pl_rep *rep = &arg.rep; + memset(&arg, 0, sizeof(arg)); req->handle = kbo->kBuf.handle; req->set_placement = slabPool->proposedPlacement & new_mask; req->clr_placement = ~slabPool->proposedPlacement & new_mask; @@ -401,6 +403,7 @@ wsbmAllocKernelBO(struct _WsbmSlabSizeHeader *header) WSBMINITLISTHEAD(&kbo->head); WSBMINITLISTHEAD(&kbo->timeoutHead); + memset(&arg, 0, sizeof(arg)); arg.req.size = size; arg.req.placement = slabPool->proposedPlacement; arg.req.page_alignment = slabPool->pageAlignment; @@ -433,8 +436,10 @@ wsbmAllocKernelBO(struct _WsbmSlabSizeHeader *header) out_err1: { - struct ttm_pl_reference_req arg = {.handle = kbo->kBuf.handle }; + struct ttm_pl_reference_req arg; + memset(&arg, 0, sizeof(arg)); + arg.handle = kbo->kBuf.handle; (void)drmCommandWrite(slabPool->pool.fd, slabPool->devOffset + TTM_PL_UNREF, &arg, sizeof(arg)); @@ -746,7 +751,7 @@ pool_create(struct _WsbmBufferPool *pool, unsigned long size, { union ttm_pl_create_arg arg; - arg.req.size = size; + memset(&arg, 0, sizeof(arg)); arg.req.placement = placement; arg.req.page_alignment = alignment / slabPool->pageSize; @@ -776,6 +781,7 @@ pool_create(struct _WsbmBufferPool *pool, unsigned long size, { struct ttm_pl_reference_req arg; + memset(&arg, 0, sizeof(arg)); arg.handle = sBuf->kBuf.handle; (void)drmCommandWriteRead(pool->fd, slabPool->devOffset + TTM_PL_UNREF, @@ -809,6 +815,7 @@ pool_destroy(struct _WsbmBufStorage **p_buf) sBuf->virtual = NULL; } + memset(&arg, 0, sizeof(arg)); arg.handle = sBuf->kBuf.handle; (void)drmCommandWrite(slabPool->pool.fd, slabPool->devOffset + TTM_PL_UNREF, diff --git a/src/wsbm_ttmpool.c b/src/wsbm_ttmpool.c index 5867428..4b8c6a2 100644 --- a/src/wsbm_ttmpool.c +++ b/src/wsbm_ttmpool.c @@ -131,6 +131,7 @@ pool_create(struct _WsbmBufferPool *pool, if (ret) goto out_err1; + memset(&arg, 0, sizeof(arg)); arg.req.size = size; arg.req.placement = placement; arg.req.page_alignment = alignment / pageSize; @@ -178,6 +179,7 @@ pool_reference(struct _WsbmBufferPool *pool, unsigned handle) if (ret) goto out_err1; + memset(&arg, 0, sizeof(arg)); arg.req.handle = handle; ret = drmCommandWriteRead(pool->fd, ttmPool->devOffset + TTM_PL_REFERENCE, &arg, sizeof(arg)); @@ -216,6 +218,8 @@ pool_destroy(struct _WsbmBufStorage **buf) (void)munmap(dBuf->virtual, dBuf->requestedSize); dBuf->virtual = NULL; } + + memset(&arg, 0, sizeof(arg)); arg.handle = dBuf->kBuf.handle; (void)drmCommandWrite(dBuf->buf.pool->fd, ttmPool->devOffset + TTM_PL_UNREF, @@ -263,6 +267,7 @@ syncforcpu_locked(struct _WsbmBufStorage *buf, unsigned mode) WSBM_MUTEX_UNLOCK(&buf->mutex); + memset(&arg, 0, sizeof(arg)); arg.handle = dBuf->kBuf.handle; arg.access_mode = kmode; arg.op = TTM_PL_SYNCCPU_OP_GRAB; @@ -303,6 +308,7 @@ releasefromcpu_locked(struct _WsbmBufStorage *buf, unsigned mode) if (kmode) { struct ttm_pl_synccpu_arg arg; + memset(&arg, 0, sizeof(arg)); arg.handle = dBuf->kBuf.handle; arg.access_mode = kmode; arg.op = TTM_PL_SYNCCPU_OP_RELEASE; @@ -420,6 +426,7 @@ pool_waitIdle(struct _WsbmBufStorage *buf, int lazy) struct _WsbmBufferPool *pool = buf->pool; int ret; + memset(&req, 0, sizeof(req)); req.handle = dBuf->kBuf.handle; req.mode = (lazy) ? TTM_PL_WAITIDLE_MODE_LAZY : 0; @@ -449,6 +456,7 @@ pool_setStatus(struct _WsbmBufStorage *buf, uint32_t set_placement, struct _WsbmBufferPool *pool = buf->pool; int ret; + memset(&arg, 0, sizeof(arg)); req->handle = dBuf->kBuf.handle; req->set_placement = set_placement; req->clr_placement = clr_placement; -- cgit v1.2.3