[Mesa-dev] [RFC 5/7] nir: fix block iterator coverity warning

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


From: Rob Clark <robclark at freedesktop.org>

For example, in nir_opt_dead_cf.c:140:

CID 1358914 (#1 of 1): Dereference null return value (NULL_RETURNS)13.
dereference: Dereferencing a null pointer block.
---
 src/compiler/nir/nir.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index a21a7bd..05209ad 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2195,7 +2195,7 @@ nir_block *nir_cf_node_cf_tree_next(nir_cf_node *node);
 
 #define nir_foreach_block_in_cf_node(block, node) \
    for (nir_block *block = nir_cf_node_cf_tree_first(node); \
-        block != nir_cf_node_cf_tree_next(node); \
+        block && (block != nir_cf_node_cf_tree_next(node)); \
         block = nir_block_cf_tree_next(block))
 
 /* If the following CF node is an if, this function returns that if.
-- 
2.5.5



More information about the mesa-dev mailing list