[Mesa-dev] [PATCH 2/5] nv30: do not use container_of() when sample param is not initialized

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue May 12 08:13:12 PDT 2015


This has been detected by Clang 3.6 which displays a warning message
because variable 'nv30' is uninitialized when used here. According to
the description of container_of, 'sample' must be initialized, otherwise
the result is undefined.

This patch gets rid of container_of() which is not required here like
for nv50 and nvc0 drivers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/drivers/nouveau/nv30/nv30_context.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.c b/src/gallium/drivers/nouveau/nv30/nv30_context.c
index 617b088..74ff395 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_context.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_context.c
@@ -36,29 +36,26 @@
 static void
 nv30_context_kick_notify(struct nouveau_pushbuf *push)
 {
-   struct nouveau_screen *screen;
-   struct nv30_context *nv30;
+   struct nv30_screen *screen = push->user_priv;
 
-   if (!push->user_priv)
+   if (!screen)
       return;
-   nv30 = container_of(push->user_priv, nv30, bufctx);
-   screen = &nv30->screen->base;
 
-   nouveau_fence_next(screen);
-   nouveau_fence_update(screen, TRUE);
+   nouveau_fence_next(&screen->base);
+   nouveau_fence_update(&screen->base, TRUE);
 
    if (push->bufctx) {
       struct nouveau_bufref *bref;
       LIST_FOR_EACH_ENTRY(bref, &push->bufctx->current, thead) {
          struct nv04_resource *res = bref->priv;
          if (res && res->mm) {
-            nouveau_fence_ref(screen->fence.current, &res->fence);
+            nouveau_fence_ref(screen->base.fence.current, &res->fence);
 
             if (bref->flags & NOUVEAU_BO_RD)
                res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING;
 
             if (bref->flags & NOUVEAU_BO_WR) {
-               nouveau_fence_ref(screen->fence.current, &res->fence_wr);
+               nouveau_fence_ref(screen->base.fence.current, &res->fence_wr);
                res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING |
                   NOUVEAU_BUFFER_STATUS_DIRTY;
             }
-- 
2.4.0



More information about the mesa-dev mailing list