mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
Fix warnings: tag.c: test_for_static()/get_tags(): Various (2): FP.
Problems : Assigned value is garbage or undefined @ 2191. Uninitialized argument value @ 2796. Diagnostic : False positives. Rationale : Both problems share the same cause. Error happens in get_tags(), if parse_match() fails because of parse_tag_line() failing before. Then, `tp` is not correctly initialized and subsequent code accesses garbage values. This is not really possible, as parse_tag_line() should not fail after find_tags() has been successful. That is because find_tags() already does tag line parsing, using parse_tag_line() itself for it (or a quicker alternative that should produce same result). That's why return value of parse_match() is ignored, and subsequent code assumes it is successful. Resolution : Assert parse_match() always successful.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
* Code to handle tags and the tag stack
|
* Code to handle tags and the tag stack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -2779,7 +2780,8 @@ int get_tags(list_T *list, char_u *pat)
|
|||||||
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
|
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
|
||||||
if (ret == OK && num_matches > 0) {
|
if (ret == OK && num_matches > 0) {
|
||||||
for (i = 0; i < num_matches; ++i) {
|
for (i = 0; i < num_matches; ++i) {
|
||||||
parse_match(matches[i], &tp);
|
int parse_result = parse_match(matches[i], &tp);
|
||||||
|
assert(parse_result == OK);
|
||||||
is_static = test_for_static(&tp);
|
is_static = test_for_static(&tp);
|
||||||
|
|
||||||
/* Skip pseudo-tag lines. */
|
/* Skip pseudo-tag lines. */
|
||||||
|
Reference in New Issue
Block a user