Remove warning about tail "potentially uninitialized"

MSVC was complaining that the `tail` variable was potentially
uninitialized in the while branch. Since the while loop is actually
coupled to the if (head != NULL) that initializes the tail variable,
we move them together, which makes the warning disappear.
This commit is contained in:
Nicolas Léveillé 2016-01-31 16:55:17 +01:00
parent d6e6911ad1
commit 206f5044a8
2 changed files with 10 additions and 9 deletions

View file

@ -52,7 +52,6 @@ HSlist* h_slist_copy(HSlist *slist) {
h_slist_push(ret, head->elem); h_slist_push(ret, head->elem);
tail = ret->head; tail = ret->head;
head = head->next; head = head->next;
}
while (head != NULL) { while (head != NULL) {
// append head item to tail in a new node // append head item to tail in a new node
HSlistNode *node = h_arena_malloc(slist->arena, sizeof(HSlistNode)); HSlistNode *node = h_arena_malloc(slist->arena, sizeof(HSlistNode));
@ -61,6 +60,7 @@ HSlist* h_slist_copy(HSlist *slist) {
tail = tail->next = node; tail = tail->next = node;
head = head->next; head = head->next;
} }
}
return ret; return ret;
} }

View file

@ -4,6 +4,7 @@ benchmark.c
bitreader.c bitreader.c
bitwriter.c bitwriter.c
cfgrammar.c cfgrammar.c
datastructures.c
desugar.c desugar.c
glue.c glue.c
hammer.c hammer.c