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:
Eliseo Martínez
2014-11-14 20:44:20 +01:00
parent 9e37c1d3b6
commit 04e42f2ae4

View File

@@ -10,6 +10,7 @@
* Code to handle tags and the tag stack
*/
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -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. */