Fix etags problems found by static checking
* lib-src/etags.c (invalidate_nodes, put_entry): Remove now-unnecessary tests for null pointers. Simplify. (put_entries): Rewrite to avoid GCC 6.2 warning about dereferencing null pointer.
This commit is contained in:
parent
4ec31277e7
commit
9166d40251
1 changed files with 22 additions and 24 deletions
|
@ -2054,8 +2054,6 @@ free_tree (register node *np)
|
||||||
|
|
||||||
while (np)
|
while (np)
|
||||||
{
|
{
|
||||||
register node *node_right;
|
|
||||||
|
|
||||||
/* Descent on left children. */
|
/* Descent on left children. */
|
||||||
while (np->left)
|
while (np->left)
|
||||||
{
|
{
|
||||||
|
@ -2063,7 +2061,7 @@ free_tree (register node *np)
|
||||||
np = np->left;
|
np = np->left;
|
||||||
}
|
}
|
||||||
/* Free node without left children. */
|
/* Free node without left children. */
|
||||||
node_right = np->right;
|
node *node_right = np->right;
|
||||||
free (np->name);
|
free (np->name);
|
||||||
free (np->regex);
|
free (np->regex);
|
||||||
free (np);
|
free (np);
|
||||||
|
@ -2169,12 +2167,11 @@ add_node (node *np, node **cur_node_p)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Ctags Mode */
|
/* Ctags Mode */
|
||||||
register int dif;
|
|
||||||
node **next_node = &cur_node;
|
node **next_node = &cur_node;
|
||||||
|
|
||||||
while ((cur_node = *next_node) != NULL)
|
while ((cur_node = *next_node) != NULL)
|
||||||
{
|
{
|
||||||
dif = strcmp (np->name, cur_node->name);
|
int dif = strcmp (np->name, cur_node->name);
|
||||||
/*
|
/*
|
||||||
* If this tag name matches an existing one, then
|
* If this tag name matches an existing one, then
|
||||||
* do not add the node, but maybe print a warning.
|
* do not add the node, but maybe print a warning.
|
||||||
|
@ -2220,9 +2217,6 @@ invalidate_nodes (fdesc *badfdp, node **npp)
|
||||||
node *np = *npp;
|
node *np = *npp;
|
||||||
stkentry *stack = NULL;
|
stkentry *stack = NULL;
|
||||||
|
|
||||||
if (np == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (CTAGS)
|
if (CTAGS)
|
||||||
{
|
{
|
||||||
while (np)
|
while (np)
|
||||||
|
@ -2240,11 +2234,13 @@ invalidate_nodes (fdesc *badfdp, node **npp)
|
||||||
{
|
{
|
||||||
/* Pop nodes from stack, invalidating them, until we find one
|
/* Pop nodes from stack, invalidating them, until we find one
|
||||||
with a right child. */
|
with a right child. */
|
||||||
do {
|
while ((np = pop_node (&stack)) != NULL)
|
||||||
np = pop_node (&stack);
|
{
|
||||||
if (np && np->fdp == badfdp)
|
if (np->fdp == badfdp)
|
||||||
np->valid = false;
|
np->valid = false;
|
||||||
} while (np && np->right == NULL);
|
if (np->right != NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Process the right child, if any. */
|
/* Process the right child, if any. */
|
||||||
if (np)
|
if (np)
|
||||||
|
@ -2253,10 +2249,10 @@ invalidate_nodes (fdesc *badfdp, node **npp)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node super_root, *np_parent;
|
node super_root, *np_parent = NULL;
|
||||||
|
|
||||||
super_root.left = np;
|
super_root.left = np;
|
||||||
super_root.fdp = (fdesc *)-1;
|
super_root.fdp = (fdesc *) -1;
|
||||||
np = &super_root;
|
np = &super_root;
|
||||||
|
|
||||||
while (np)
|
while (np)
|
||||||
|
@ -2273,7 +2269,9 @@ invalidate_nodes (fdesc *badfdp, node **npp)
|
||||||
np_parent->left = np->left; /* detach subtree from the tree */
|
np_parent->left = np->left; /* detach subtree from the tree */
|
||||||
np->left = NULL; /* isolate it */
|
np->left = NULL; /* isolate it */
|
||||||
free_tree (np); /* free it */
|
free_tree (np); /* free it */
|
||||||
np = np_parent->left; /* continue with rest of tree */
|
|
||||||
|
/* Continue with rest of tree. */
|
||||||
|
np = np_parent ? np_parent->left : NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*npp = super_root.left;
|
*npp = super_root.left;
|
||||||
|
@ -2321,13 +2319,13 @@ total_size_of_entries (register node *np)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
put_entry (register node *np)
|
put_entry (node *np)
|
||||||
{
|
{
|
||||||
register char *sp;
|
register char *sp;
|
||||||
static fdesc *fdp = NULL;
|
static fdesc *fdp = NULL;
|
||||||
|
|
||||||
/* Output this entry */
|
/* Output this entry */
|
||||||
if (np && np->valid)
|
if (np->valid)
|
||||||
{
|
{
|
||||||
if (!CTAGS)
|
if (!CTAGS)
|
||||||
{
|
{
|
||||||
|
@ -2394,7 +2392,7 @@ put_entry (register node *np)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
put_entries (register node *np)
|
put_entries (node *np)
|
||||||
{
|
{
|
||||||
stkentry *stack = NULL;
|
stkentry *stack = NULL;
|
||||||
|
|
||||||
|
@ -2414,13 +2412,13 @@ put_entries (register node *np)
|
||||||
/* Output this subentry. */
|
/* Output this subentry. */
|
||||||
put_entry (np);
|
put_entry (np);
|
||||||
/* Stack subentries that follow this one. */
|
/* Stack subentries that follow this one. */
|
||||||
if (!np->right)
|
while (!np->right)
|
||||||
{
|
{
|
||||||
/* Output subentries that precede the next one. */
|
/* Output subentries that precede the next one. */
|
||||||
do {
|
np = pop_node (&stack);
|
||||||
np = pop_node (&stack);
|
if (!np)
|
||||||
put_entry (np);
|
break;
|
||||||
} while (np && np->right == NULL);
|
put_entry (np);
|
||||||
}
|
}
|
||||||
if (np)
|
if (np)
|
||||||
np = np->right;
|
np = np->right;
|
||||||
|
|
Loading…
Add table
Reference in a new issue