Suppress 'value computed is not used' warning on gcc

This commit is contained in:
Max Brunsfeld 2016-11-05 14:39:25 -07:00
parent 4106ecda43
commit ca45acd6af
3 changed files with 15 additions and 19 deletions

View file

@ -41,10 +41,9 @@ extern "C" {
#define array_delete(self) array__delete((VoidArray *)self)
#define array_push(self, element) \
((self)->size < (self)->capacity || \
(array_grow((self), (self)->capacity ? (self)->capacity * 2 : 8), true), \
(self)->contents[(self)->size++] = (element))
#define array_push(self, element) \
(array_grow((self), (self)->size + 1), \
(self)->contents[(self)->size++] = (element))
#define array_splice(self, index, old_count, new_count, new_elements) \
array__splice((VoidArray *)(self), array__elem_size(self), index, old_count, \
@ -83,14 +82,15 @@ static inline void array__erase(VoidArray *self, size_t element_size,
static inline void array__grow(VoidArray *self, size_t element_size,
size_t new_capacity) {
if (new_capacity > self->capacity) {
void *new_contents;
if (new_capacity < 2 * self->capacity)
new_capacity = 2 * self->capacity;
if (new_capacity < 8)
new_capacity = 8;
if (self->contents)
new_contents = ts_realloc(self->contents, new_capacity * element_size);
self->contents = ts_realloc(self->contents, new_capacity * element_size);
else
new_contents = ts_calloc(new_capacity, element_size);
self->contents = ts_calloc(new_capacity, element_size);
self->capacity = new_capacity;
self->contents = new_contents;
}
}

View file

@ -79,8 +79,11 @@ static void stack_node_release(StackNode *self, StackNodeArray *pool) {
stack_node_release(self->links[i].node, pool);
}
if (pool->size >= MAX_NODE_POOL_SIZE || !array_push(pool, self))
if (pool->size < MAX_NODE_POOL_SIZE) {
array_push(pool, self);
} else {
ts_free(self);
}
}
}
@ -602,8 +605,7 @@ bool ts_stack_print_dot_graph(Stack *self, const char **symbol_names, FILE *f) {
}
}
if (!array_push(&visited_nodes, node))
goto error;
array_push(&visited_nodes, node);
}
}
@ -612,10 +614,4 @@ bool ts_stack_print_dot_graph(Stack *self, const char **symbol_names, FILE *f) {
array_delete(&visited_nodes);
ts_toggle_allocation_recording(was_recording_allocations);
return true;
error:
ts_toggle_allocation_recording(was_recording_allocations);
if (visited_nodes.contents)
array_delete(&visited_nodes);
return false;
}

View file

@ -80,7 +80,7 @@ static size_t tree_path_advance(TreePath *path) {
static void tree_path_ascend(TreePath *path, size_t count) {
for (size_t i = 0; i < count; i++) {
do {
array_pop(path);
path->size--;
} while (path->size > 0 && !array_back(path)->tree->visible);
}
}