locate: initialize the whole visited_types array

The declaration initialized only the first element.  Initialize the
whole array with memset() instead.
This commit is contained in:
Max Kellermann 2009-01-24 15:27:09 +01:00
parent 535cf5b5c9
commit e100149124
1 changed files with 6 additions and 2 deletions

View File

@ -130,7 +130,7 @@ locate_tag_search(const struct song *song, enum tag_type type, const char *str)
int i; int i;
char *duplicate; char *duplicate;
bool ret = false; bool ret = false;
bool visited_types[TAG_NUM_OF_ITEM_TYPES] = { false }; bool visited_types[TAG_NUM_OF_ITEM_TYPES];
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) { if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
char *uri, *p; char *uri, *p;
@ -149,6 +149,8 @@ locate_tag_search(const struct song *song, enum tag_type type, const char *str)
if (!song->tag) if (!song->tag)
return false; return false;
memset(visited_types, 0, sizeof(visited_types));
for (i = 0; i < song->tag->numOfItems && !ret; i++) { for (i = 0; i < song->tag->numOfItems && !ret; i++) {
visited_types[song->tag->items[i]->type] = true; visited_types[song->tag->items[i]->type] = true;
if (type != LOCATE_TAG_ANY_TYPE && if (type != LOCATE_TAG_ANY_TYPE &&
@ -189,7 +191,7 @@ static bool
locate_tag_match(const struct song *song, enum tag_type type, const char *str) locate_tag_match(const struct song *song, enum tag_type type, const char *str)
{ {
int i; int i;
bool visited_types[TAG_NUM_OF_ITEM_TYPES] = { false }; bool visited_types[TAG_NUM_OF_ITEM_TYPES];
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) { if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
char *uri = song_get_uri(song); char *uri = song_get_uri(song);
@ -206,6 +208,8 @@ locate_tag_match(const struct song *song, enum tag_type type, const char *str)
if (!song->tag) if (!song->tag)
return false; return false;
memset(visited_types, 0, sizeof(visited_types));
for (i = 0; i < song->tag->numOfItems; i++) { for (i = 0; i < song->tag->numOfItems; i++) {
visited_types[song->tag->items[i]->type] = true; visited_types[song->tag->items[i]->type] = true;
if (type != LOCATE_TAG_ANY_TYPE && if (type != LOCATE_TAG_ANY_TYPE &&