[Mesa-dev] [RFC 7/7] nir/validate: assume() that hashtable entry exists

Rob Clark robdclark at gmail.com
Wed May 18 15:54:15 UTC 2016


From: Rob Clark <robclark at freedesktop.org>

At this point, it would require a logic error in nir_validate to not
have already populated this hashtable entry, but coverity doesn't
realize that:

CID 1265547 (#1 of 1): Dereference null return value (NULL_RETURNS)3.
dereference: Dereferencing a null pointer entry.

CID 1271039 (#1 of 1): Dereference null return value (NULL_RETURNS)3.
dereference: Dereferencing a null pointer entry.
---
 src/compiler/nir/nir_validate.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index fa51e3c..35bb162 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -880,6 +880,7 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
 {
    struct hash_entry *entry = _mesa_hash_table_search(state->regs, reg);
 
+   assume(entry);
    reg_validate_state *reg_state = (reg_validate_state *) entry->data;
 
    nir_foreach_use(src, reg) {
@@ -956,6 +957,8 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state)
    validate_state *state = void_state;
 
    struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, def);
+
+   assume(entry);
    ssa_def_validate_state *def_state = (ssa_def_validate_state *)entry->data;
 
    nir_foreach_use(src, def) {
-- 
2.5.5



More information about the mesa-dev mailing list