[Nouveau] [PATCH] nv50: Fix broken assertion

Daniel Stone
Tue, 07 Feb 2012 12:15:34 -0000

The assertion added in f09910f3 broke nv50 completely by asserting that
the number of elements in a dereferenced pointer (i.e. 1) was greater
than i (which ranged up to six), rather than checking the number of
elements in the containing array.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/gallium/drivers/nv50/nv50_pc_regalloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_pc_regalloc.c
b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
index 72922cb..12a59cb 100644
--- a/src/gallium/drivers/nv50/nv50_pc_regalloc.c
+++ b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
@@ -421,7 +421,7 @@ phi_opnd_for_bb(struct nv_instruction *phi, struct
nv_basic_block *b,
    int i, j;

    for (j = -1, i = 0; i < 6 && phi->src[i]; ++i) {
-      assert(i < Elements(phi->src[i]));
+      assert(i < Elements(phi->src));
       srci = phi->src[i];
       /* if already replaced, check with original source first */
       if (srci->flags & NV_REF_FLAG_REGALLOC_PRIV)
--
1.7.9