aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2016-08-31 10:11:16 -0700
committerPaul Eggert2016-08-31 10:15:45 -0700
commit9166d4025197d0109015f1c7a77e78dce63d3312 (patch)
treed91a1f88465850938b712bd2e9f1634e599cb8a1 /lib-src
parent4ec31277e7603484fd7a4d2d8e3d0eefe62c587c (diff)
downloademacs-9166d4025197d0109015f1c7a77e78dce63d3312.tar.gz
emacs-9166d4025197d0109015f1c7a77e78dce63d3312.zip
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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index bf4a8f7015d..77dcaf030d6 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -2054,8 +2054,6 @@ free_tree (register node *np)
2054 2054
2055 while (np) 2055 while (np)
2056 { 2056 {
2057 register node *node_right;
2058
2059 /* Descent on left children. */ 2057 /* Descent on left children. */
2060 while (np->left) 2058 while (np->left)
2061 { 2059 {
@@ -2063,7 +2061,7 @@ free_tree (register node *np)
2063 np = np->left; 2061 np = np->left;
2064 } 2062 }
2065 /* Free node without left children. */ 2063 /* Free node without left children. */
2066 node_right = np->right; 2064 node *node_right = np->right;
2067 free (np->name); 2065 free (np->name);
2068 free (np->regex); 2066 free (np->regex);
2069 free (np); 2067 free (np);
@@ -2169,12 +2167,11 @@ add_node (node *np, node **cur_node_p)
2169 else 2167 else
2170 { 2168 {
2171 /* Ctags Mode */ 2169 /* Ctags Mode */
2172 register int dif;
2173 node **next_node = &cur_node; 2170 node **next_node = &cur_node;
2174 2171
2175 while ((cur_node = *next_node) != NULL) 2172 while ((cur_node = *next_node) != NULL)
2176 { 2173 {
2177 dif = strcmp (np->name, cur_node->name); 2174 int dif = strcmp (np->name, cur_node->name);
2178 /* 2175 /*
2179 * If this tag name matches an existing one, then 2176 * If this tag name matches an existing one, then
2180 * do not add the node, but maybe print a warning. 2177 * do not add the node, but maybe print a warning.
@@ -2220,9 +2217,6 @@ invalidate_nodes (fdesc *badfdp, node **npp)
2220 node *np = *npp; 2217 node *np = *npp;
2221 stkentry *stack = NULL; 2218 stkentry *stack = NULL;
2222 2219
2223 if (np == NULL)
2224 return;
2225
2226 if (CTAGS) 2220 if (CTAGS)
2227 { 2221 {
2228 while (np) 2222 while (np)
@@ -2240,11 +2234,13 @@ invalidate_nodes (fdesc *badfdp, node **npp)
2240 { 2234 {
2241 /* Pop nodes from stack, invalidating them, until we find one 2235 /* Pop nodes from stack, invalidating them, until we find one
2242 with a right child. */ 2236 with a right child. */
2243 do { 2237 while ((np = pop_node (&stack)) != NULL)
2244 np = pop_node (&stack); 2238 {
2245 if (np && np->fdp == badfdp) 2239 if (np->fdp == badfdp)
2246 np->valid = false; 2240 np->valid = false;
2247 } while (np && np->right == NULL); 2241 if (np->right != NULL)
2242 break;
2243 }
2248 } 2244 }
2249 /* Process the right child, if any. */ 2245 /* Process the right child, if any. */
2250 if (np) 2246 if (np)
@@ -2253,10 +2249,10 @@ invalidate_nodes (fdesc *badfdp, node **npp)
2253 } 2249 }
2254 else 2250 else
2255 { 2251 {
2256 node super_root, *np_parent; 2252 node super_root, *np_parent = NULL;
2257 2253
2258 super_root.left = np; 2254 super_root.left = np;
2259 super_root.fdp = (fdesc *)-1; 2255 super_root.fdp = (fdesc *) -1;
2260 np = &super_root; 2256 np = &super_root;
2261 2257
2262 while (np) 2258 while (np)
@@ -2273,7 +2269,9 @@ invalidate_nodes (fdesc *badfdp, node **npp)
2273 np_parent->left = np->left; /* detach subtree from the tree */ 2269 np_parent->left = np->left; /* detach subtree from the tree */
2274 np->left = NULL; /* isolate it */ 2270 np->left = NULL; /* isolate it */
2275 free_tree (np); /* free it */ 2271 free_tree (np); /* free it */
2276 np = np_parent->left; /* continue with rest of tree */ 2272
2273 /* Continue with rest of tree. */
2274 np = np_parent ? np_parent->left : NULL;
2277 } 2275 }
2278 } 2276 }
2279 *npp = super_root.left; 2277 *npp = super_root.left;
@@ -2321,13 +2319,13 @@ total_size_of_entries (register node *np)
2321} 2319}
2322 2320
2323static void 2321static void
2324put_entry (register node *np) 2322put_entry (node *np)
2325{ 2323{
2326 register char *sp; 2324 register char *sp;
2327 static fdesc *fdp = NULL; 2325 static fdesc *fdp = NULL;
2328 2326
2329 /* Output this entry */ 2327 /* Output this entry */
2330 if (np && np->valid) 2328 if (np->valid)
2331 { 2329 {
2332 if (!CTAGS) 2330 if (!CTAGS)
2333 { 2331 {
@@ -2394,7 +2392,7 @@ put_entry (register node *np)
2394} 2392}
2395 2393
2396static void 2394static void
2397put_entries (register node *np) 2395put_entries (node *np)
2398{ 2396{
2399 stkentry *stack = NULL; 2397 stkentry *stack = NULL;
2400 2398
@@ -2414,13 +2412,13 @@ put_entries (register node *np)
2414 /* Output this subentry. */ 2412 /* Output this subentry. */
2415 put_entry (np); 2413 put_entry (np);
2416 /* Stack subentries that follow this one. */ 2414 /* Stack subentries that follow this one. */
2417 if (!np->right) 2415 while (!np->right)
2418 { 2416 {
2419 /* Output subentries that precede the next one. */ 2417 /* Output subentries that precede the next one. */
2420 do { 2418 np = pop_node (&stack);
2421 np = pop_node (&stack); 2419 if (!np)
2422 put_entry (np); 2420 break;
2423 } while (np && np->right == NULL); 2421 put_entry (np);
2424 } 2422 }
2425 if (np) 2423 if (np)
2426 np = np->right; 2424 np = np->right;