Pacify GCC 13 -Wnull-dereference in itree.c

* src/itree.c (itree_remove_fix): Simplify code and remove a
couple of eassume calls.  This works around GCC bug 109586.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109856
This commit is contained in:
Paul Eggert 2023-05-14 18:51:23 -07:00
parent 0c11c2ae71
commit 919e1b81a4

View file

@ -817,14 +817,13 @@ itree_remove_fix (struct itree_tree *tree,
{
struct itree_node *other = parent->right;
if (null_safe_is_red (other)) /* case 1.a */
if (other->red) /* case 1.a */
{
other->red = false;
parent->red = true;
itree_rotate_left (tree, parent);
other = parent->right;
}
eassume (other != NULL);
if (null_safe_is_black (other->left) /* 2.a */
&& null_safe_is_black (other->right))
@ -855,14 +854,13 @@ itree_remove_fix (struct itree_tree *tree,
{
struct itree_node *other = parent->left;
if (null_safe_is_red (other)) /* 1.b */
if (other->red) /* 1.b */
{
other->red = false;
parent->red = true;
itree_rotate_right (tree, parent);
other = parent->left;
}
eassume (other != NULL);
if (null_safe_is_black (other->right) /* 2.b */
&& null_safe_is_black (other->left))