From 04e42f2ae409294d551c9b589aee4cbfd2616d68 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Fri, 14 Nov 2014 20:44:20 +0100 Subject: 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. --- src/nvim/tag.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvim/tag.c b/src/nvim/tag.c index e267280bbd..816e9902fe 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -10,6 +10,7 @@ * Code to handle tags and the tag stack */ +#include #include #include #include @@ -2779,7 +2780,8 @@ int get_tags(list_T *list, char_u *pat) TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL); if (ret == OK && num_matches > 0) { 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); /* Skip pseudo-tag lines. */ -- cgit