ctf, ctf-writer: Fix -Wnull-dereference warnings
[babeltrace.git] / src / ctf-writer / resolve.c
index 7bcc924c4024e8510ce287d264c7dbe3e7e158eb..4636e1c55348786ec6122624ba5cc94244606980 100644 (file)
@@ -201,15 +201,10 @@ size_t type_stack_size(type_stack *stack)
 static
 struct type_stack_frame *type_stack_peek(type_stack *stack)
 {
-       struct type_stack_frame *entry = NULL;
+       BT_ASSERT(stack);
+       BT_ASSERT(!type_stack_empty(stack));
 
-       if (!stack || type_stack_empty(stack)) {
-               goto end;
-       }
-
-       entry = g_ptr_array_index(stack, stack->len - 1);
-end:
-       return entry;
+       return g_ptr_array_index(stack, stack->len - 1);
 }
 
 /*
@@ -218,19 +213,12 @@ end:
  * Return value is owned by `stack`.
  */
 static
-struct type_stack_frame *type_stack_at(type_stack *stack,
-               size_t index)
+struct type_stack_frame *type_stack_at(type_stack *stack, size_t index)
 {
-       struct type_stack_frame *entry = NULL;
+       BT_ASSERT(stack);
+       BT_ASSERT(index < stack->len);
 
-       if (!stack || index >= stack->len) {
-               goto end;
-       }
-
-       entry = g_ptr_array_index(stack, index);
-
-end:
-       return entry;
+       return g_ptr_array_index(stack, index);
 }
 
 /*
This page took 0.023278 seconds and 4 git commands to generate.