[Mesa-dev] [PATCH 1/5] nir: Make nir_block_{first, last}_instr return NULL for empty blocks.
Kenneth Graunke
kenneth at whitecape.org
Tue Aug 25 13:24:04 PDT 2015
This is a lot more reasonable than returning an offset from NULL.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/glsl/nir/nir.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 40871f7..12ddeb2 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1219,14 +1219,14 @@ static inline nir_instr *
nir_block_first_instr(nir_block *block)
{
struct exec_node *head = exec_list_get_head(&block->instr_list);
- return exec_node_data(nir_instr, head, node);
+ return head ? exec_node_data(nir_instr, head, node) : NULL;
}
static inline nir_instr *
nir_block_last_instr(nir_block *block)
{
struct exec_node *tail = exec_list_get_tail(&block->instr_list);
- return exec_node_data(nir_instr, tail, node);
+ return tail ? exec_node_data(nir_instr, tail, node) : NULL;
}
#define nir_foreach_instr(block, instr) \
--
2.5.0
More information about the mesa-dev
mailing list