Skip to content

Commit

Permalink
fix sonarqube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GIC-de committed Nov 28, 2024
1 parent ff0cc88 commit cee644a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/pr_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ node_verify(const pr_tree* tree, const pr_node* parent, const pr_node* node)
unsigned lweight = WEIGHT(l);
unsigned rweight = WEIGHT(r);
VERIFY(node->weight == lweight + rweight);
if (rweight > lweight) {
if (r && rweight > lweight) {
VERIFY(WEIGHT(r->rlink) <= lweight);
VERIFY(WEIGHT(r->llink) <= lweight);
} else if (lweight > rweight) {
} else if (l && lweight > rweight) {
VERIFY(WEIGHT(l->llink) <= rweight);
VERIFY(WEIGHT(l->rlink) <= rweight);
}
Expand Down
2 changes: 1 addition & 1 deletion src/skiplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ node_insert(skiplist* list, skip_node* x, skip_node** update)
}

x->prev = (update[0] == list->head) ? NULL : update[0];
if (update[0]->link[0])
if (update[0]->link && update[0]->link[0])
update[0]->link[0]->prev = x;
for (unsigned k = 0; k < nlinks; k++) {
ASSERT(update[k]->link_count > k);
Expand Down
12 changes: 10 additions & 2 deletions src/tree_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,22 @@ bool
tree_iterator_next(void* Iterator)
{
tree_iterator* iterator = Iterator;
return (iterator->node != NULL) && (iterator->node = tree_node_next(iterator->node)) != NULL;
if(iterator->node) {
iterator->node = tree_node_next(iterator->node);
if(iterator->node) return true;
}
return false;
}

bool
tree_iterator_prev(void* Iterator)
{
tree_iterator* iterator = Iterator;
return (iterator->node != NULL) && (iterator->node = tree_node_prev(iterator->node)) != NULL;
if(iterator->node) {
iterator->node = tree_node_prev(iterator->node);
if(iterator->node) return true;
}
return false;
}

bool
Expand Down

0 comments on commit cee644a

Please sign in to comment.